Return to Snippet

Revision: 36881
at November 29, 2010 11:57 by mikemore


Initial Code
// 1- Get User's Tweets Count
function getTweetCount(username,n) {
   $.ajax({
      url:'http://twitter.com/users/show.json'
      ,data:{screen_name:username}
      ,dataType:'jsonp'
      ,success:function(json){
         // Can not go back more than 3200 tweet
         var min = json.statuses_count-3200;
         // min can not be less than 0
         if(min<0) min =0;
         // n has to be greater than min and less than tweet count
         if(n>min && n<=json.statuses_count) {
            // page = count - Nth + 1
            getLatestTweet(username, json.statuses_count - n + 1);
         }
      }
   });
}


// 2- Get User's Nth Tweet
function getLatestTweet(username,page) {
   $.ajax({
      url:'http://twitter.com/statuses/user_timeline.json'
      ,data:{screen_name:username,count:1,page:page}
      ,dataType:'jsonp'
      ,success:function(json){
         if(json.length) showTweet(json[0]);
      }
   });
}

Initial URL
http://www.moretechtips.net/2010/02/nearing-my-1000th-tweet-using-jquery-to.html

Initial Description
As of my ongoing preparation for the 1K tweet :) I was interested to see the 1000th tweet from some friends timeline. And when I didn't find an existing method, I thought I could write few jQuery lines to solve this..

Initial Title
Using jQuery to Get the Nth Twitter Status

Initial Tags
ajax, json, twitter

Initial Language
jQuery