json - Custom Twitter Widget - Limit the number of tweets -


i followed tutorial create custom twitter widget. uses twitter api, json pull tweets.

http://www.evoluted.net/thinktank/web-development/creating-your-own-twitter-trends-widget

as in tutorial have got tweets. limit number of tweets appear maybe 2.

site - http://testingweddev.comli.com/

add rpp= parameter url

$(document).ready(function() {   // json call twitter request tweets containing our keyword, in case 'sheffield'   $.getjson("http://search.twitter.com/search.json?q=sheffield&rpp=2&callback=?", function(data) {     // loop around result     $.each(data.results, function() {       var text = this.text;        if(text.charat(0) != '@') {         // construct tweet , add append our #tweets div         var tweet = $("<div></div>").addclass('tweet').html(text);         // analyse our tweet text , turn urls working links, hash tags search links, , @replies profile links.         tweet.html('<div class="content">' +            tweet.html()           .replace(/((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\s+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi,'<a href="$1">$1</a>')           .replace(/(^|\s)#(\w+)/g,'$1<a href="http://search.twitter.com/search?q=%23$2">#$2</a>')           .replace(/(^|\s)@(\w+)/g,'$1<a href="http://twitter.com/$2">@$2</a>')           + '<br /><a href="http://www.twitter.com/' + this.from_user + '/status/' + this.id_str + '" class="view" target="_blank">' + $.timesincetweet(this.created_at) + '</a></div>'           )           .prepend('<a href="http://www.twitter.com/' + this.from_user + '" target="_blank"><img src="' + this.profile_image_url + '" width="48" height="48" /></a>')           .appendto('#tweets')           .fadein();       }     });   }); }); 

and don't forget switch api 1.1. see api 1.1 search documentation. api 1.1 uses count param specify tweets limit.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -