This loads up a Twitter feed and displays the last tweet.
Is there a way to include and retrieve all the retweets in this function?
$(document).ready(function() {
var url = "http://twitter.com/status/user_timeline/mytwittername.json?count=3&callback=?";
var lastClass = "";
$.getJSON(url,
function(data){
$.each(data, function(i, item) {
// check for last tweet
if (i == (data.length - 1)) {
lastClass = "class='last'"
}
$("#twitter-content ul").append("<li " + lastClass + ">" + item.text.linkify().atify() + " <span class='created_at'>[" + relative_time(item.created_at) + " via " + item.source + "]</span></li>");
});
});
$("#sidebar ul li:last-child").addClass("last");
});
Modify the
urlvariable in your code to be the following:The magic is in the
include_rts=1parameter which will cause retweets by the target user to be included in their timeline.The statuses/user_timeline method does not require authentication, however if you do auth, you’ll get an extra 200 API calls per hour. Note that the
twitter.comREST methods are no longer supported, so be sure to use the versioned API methods when interacting with Twitter.