Last active
August 29, 2015 13:58
-
-
Save csim/10285505 to your computer and use it in GitHub Desktop.
Embed tweets to blog
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
<div id="tweet"></div> |
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
<script type="text/javascript"> | |
function urlize(input) { | |
var exp = /(\b(https?|ftp|file):\/\/([-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|]))/ig; | |
output = input.replace(exp,'<a href="$1">$3</a>'); | |
return output; | |
} | |
function tweep(input) { | |
var exp = /(\@(\w+?)) /ig; | |
output = input.replace(exp,'<a href="http://www.twitter.com/$2">$1</a> '); | |
return output; | |
} | |
</script> |
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
<script src="http://code.jquery.com/jquery-1.6.2.min.js"></script> |
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
<script type="text/javascript"> | |
$(document).ready(function() { | |
var url = 'http://api.twitter.com/1/statuses/user_timeline/<username>.json?callback=?' | |
$.getJSON(url, function(data) { | |
$("#tweet").html(tweep(urlize(data[0].text))); | |
}); | |
}); | |
</script> |
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
<script type="text/javascript"> | |
$(document).ready(function() { | |
var u = 'techhike'; | |
var url = 'http://api.twitter.com/1/statuses/user_timeline/' | |
+ u + '.json?callback=?'; | |
$.getJSON(url, function(data) { | |
$("#tweet").html(data[0].text)); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment