Using jQuery to Get the Nth Twitter Status


/ Published in: jQuery
Save to your folder(s)

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..


Copy this code and paste it in your HTML
  1. // 1- Get User's Tweets Count
  2. function getTweetCount(username,n) {
  3. $.ajax({
  4. url:'http://twitter.com/users/show.json'
  5. ,data:{screen_name:username}
  6. ,dataType:'jsonp'
  7. ,success:function(json){
  8. // Can not go back more than 3200 tweet
  9. var min = json.statuses_count-3200;
  10. // min can not be less than 0
  11. if(min<0) min =0;
  12. // n has to be greater than min and less than tweet count
  13. if(n>min && n<=json.statuses_count) {
  14. // page = count - Nth + 1
  15. getLatestTweet(username, json.statuses_count - n + 1);
  16. }
  17. }
  18. });
  19. }
  20.  
  21.  
  22. // 2- Get User's Nth Tweet
  23. function getLatestTweet(username,page) {
  24. $.ajax({
  25. url:'http://twitter.com/statuses/user_timeline.json'
  26. ,data:{screen_name:username,count:1,page:page}
  27. ,dataType:'jsonp'
  28. ,success:function(json){
  29. if(json.length) showTweet(json[0]);
  30. }
  31. });
  32. }

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.