Created
June 4, 2015 19:19
-
-
Save leklund/2234ec95df1cd292fff7 to your computer and use it in GitHub Desktop.
Generate Tweet Intent URL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> | |
<title>twitter link gen</title> | |
<script> | |
$(function() { | |
$("#twtgen").submit(function() { | |
var url = 'https://twitter.com/intent/tweet'; | |
var params = '?' | |
$('#twtgen input').each(function(i) { | |
if ($(this).val()) { | |
var param = $(this).attr('name') + '=' + encodeURIComponent($(this).val()); | |
params = params + param + '&'; | |
} | |
}); | |
params = params.replace(/&$/,''); | |
$("#tweetLink").val(url + params); | |
return false; | |
}); | |
$("#tweetLink").click(function() { | |
$(this).select(); | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<div class="container"> | |
<h1>Tweet Link Generator</h1> | |
<p>Generates a <a href='https://dev.twitter.com/web/tweet-button/web-intent'>Tweet Web Intent</a> URL. Makes it easy to add | |
a tweet link without additional javascript of iframes from Twitter.</p> | |
<form id="twtgen"> | |
<div class='form-group'> | |
<label>Tweet Text</label> | |
<input type='text' class='form-control' id='tweetText' name='text'> | |
</div> | |
<div class='form-group'> | |
<label>Tweet URL</label> | |
<input type='text' class='form-control' id='tweetUrl' name='url'> | |
</div> | |
<div class='form-group'> | |
<label>Hashtags</label> | |
<input type='text' class='form-control' id='tweetHashtags' name='hashtags'> | |
</div> | |
<div class='form-group'> | |
<label>Via</label> | |
<input type='text' class='form-control' id='tweetVia' name='via'> | |
</div> | |
<div class='form-group'> | |
<label>Related</label> | |
<input type='text' class='form-control' id='tweetRelated' name='related'> | |
</div> | |
<div class='form-group'> | |
<label>In-reply-to</label> | |
<input type='text' class='form-control' id='tweetReply' name='in-reply-to'> | |
</div> | |
<button type="submit" class="btn btn-primary">Generate</button> | |
</form> | |
<hr> | |
<form> | |
<div class='form-group'> | |
<label>Tweet Link</label> | |
<input type='text' class='form-control' id='tweetLink'> | |
</div> | |
</div> | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment