Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
/*
Javascript interface to Twitter search API.
Call it like
Twitter.search({q:'"is down'",
callback:function(data){
doSomethingAwesome(data)
}
})
You can also use any of the other options like lang, since_id, etc.
It should be framework agnostic too. Though, I like prototype.
*/
Twitter = {
_callbacks:{}
};
Twitter.search = function(opts){
//opts.q
//opts.since_id
//opts.rpp
//opts.lang
//opts.page
//opts.callback
var query_parts=[];
for(key in opts)
{
if(key!='callback')
query_parts.push(escape(key)+'='+escape(opts[key]));
}
var key = "c"+Date.now().toString()
Twitter._callbacks[key] = function(data){
opts.callback(data.results);
delete Twitter._callbacks[key]
}
query_parts.push("callback=Twitter._callbacks."+key)
var body = document.getElementsByTagName("body")[0];
var script = document.createElement("script");
script.src = "http://search.twitter.com/search.json?"+query_parts.join("&")
body.appendChild(script)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.