jQuery: using jTwitter on a Twitter feed

jTwitter is a powerful jQuery plugin created to parse a Twitter feed in JSON format. This plugin adds a new global function to the jQuery wrapper and encapsulates the popular global getJSON() method. Also, this plugin allow us to limit the number of tweets returned by the JSON object obtained by the AJAX request (performed using the JSONP standard). Further, we can work on the single properties of such an object by iterating over them using $.each(). An example:

$(document).ready(function(){
 
 $.jTwitter('username', 5, function(data){
  $('#posts').empty();
  $.each(data, function(i, post){
      
   var tweet = post.text;
   
   $('#posts').append(
    '<div class="post">'
    +' <div class="txt">'
    +    tweet
    +' </div>'
    +'</div>'
   );

   
   
  });
 });
 
});

As you can see, this plugin accepts a Twitter username, the number of returned tweets and the JSON object itself.

Demo

Live demo

Leave a Reply

Note: Only a member of this blog may post a comment.