-
-
Save TastyToast/2770850 to your computer and use it in GitHub Desktop.
Twitter Intents with Rawtext
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
<button id="tweet_button">Click to Tweet</button> | |
<script type="text/javascript"> | |
{% plugin rawtext tweet_url %} | |
{% plugin rawtext tweet_text %} | |
{% plugin rawtext tweet_hashtags %} | |
var params = {}; | |
{% if tweet_url %} | |
params.url: '{{ tweet_url | escape }}'; | |
{% endif %} | |
{% if tweet_text %} | |
params.text: '{{ tweet_text | escape }}'; | |
{% endif %} | |
{% if tweet_hashtags %} | |
params.hashtags: '{{ tweet_hashtags | escape }}'; | |
{% endif %} | |
var intent_url = 'https://twitter.com/intent/tweet?' + $.param(params); | |
$('#tweet_button').click( function (e) { | |
e.preventDefault(); | |
window.open(intent_url, 'tweet_intent'); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment