Recently I’ve been doing quite a bit of work with twitter’s searching api for an app I’ve been working on, and today I’m proud to announce that the jquery plugin I’ve written for it is now available on github as jquery-twitter for download.
Let me be frank, this isn’t something fancy like monitter or other similar tools that you can just smack on a website… rather, it’s a library that provide a javascript api to include twitter based stuff in your application.
Currently it supports much of the API, and all of the arguments each API call takes. Essentially, it all works if it doesn’t require authentication.
Searching
To do a simple search:
$.twitter.search('#followfriday', function(response){
$(response.results).each(function(){
$('body').append('
'+this.text+'
');
});
});
You can also pass any of the search api parameters in as an optional second argument. Say I want to search for #followfriday in spanish, with 20 results per page:
$.twitter.search('#followfriday', {rpp:20, lang:'es'}, function(response){
$(response.results).each(function(){
$('body').append('
'+this.text+'
');
});
});
The geocode parameters are setup in a little more structured feel. To search for terms 50 miles near 40.757929,-73.985506:
$.twitter.search('#followfriday', {geocode:{lat:40.757929, lon:-73.985506, radius:'50m'}}, function(response){
$(response.results).each(function(){
$('body').append('
'+this.text+'
');
});
});
Alternatively, there’s a live search feature… it’s used just like the search method, however it researches twitter every 2 seconds and calls the callback with any new results since the last search.
$.twitter.liveSearch('#followfriday', {rpp:20, lang:'es'}, function(response){
$(response.results).each(function(){
$('body').append('
'+this.text+'
');
});
});
The live search has a ton of features on it’s own, with special events that you can trigger or subscribe to, but I will cover that in more depth once the API around it becomes more solid.
Trends
Trends are pretty straightforward with three different methods for trends:
$.twitter.current(function(response){});
$.twitter.daily(function(response){});
$.twitter.weekly(function(response){});
User Timeline
Finally, you can get a user’s public timeline via
$.twitter.user_timeline('jamescarr', function(resp){
$('body').append('
'+this.user.name+': '+this.text+'
');
});
That about wraps it up… this is a very fresh and will be constantly evolving as I improve it, so stay tuned for future improvements. 