Created
October 30, 2012 11:16
-
-
Save Chrisedmo/3979662 to your computer and use it in GitHub Desktop.
Quick JS tweets for static site.
This file contains hidden or 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
$(document).ready(function () { | |
// Type in your twitter id here | |
var user = 'TWITTERID'; | |
// How many Tweets do you want to display? | |
//Type in the number after &count= | |
// Do you wanna show RT's? include_rts= '0 for no' or '1 for yes' | |
$.getJSON('http://api.twitter.com/1/statuses/user_timeline.json?screen_name=' + user + '&count=3&include_rts=1&callback=?', function(data) { | |
var tweet = ""; | |
for (i = 0; i < data.length; i++) { | |
tweet += data[i].text + "</br></br>"; | |
} | |
tweet = tweet.replace(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig, function(url) { | |
return '<a target="_blank" href="'+url+'">'+url+'</a>'; | |
}).replace(/B@([_a-z0-9]+)/ig, function(reply) { | |
return reply.charAt(0)+'<a href="http://twitter.com/'+reply.substring(1)+'">'+reply.substring(1)+'</a>'; | |
}); | |
// Give your tweets a home: here an element of id tweet (#tweet) | |
$("#tweet").html(tweet); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Source: http://shoogledesigns.com/blog/blog/2012/10/30/reminder-quick-and-easy-way-to-display-tweets-on-a-static-website/