Twitter Search is turning out to be a very powerful force in real-time search. Instead of relying on a vaguely-defined, possibly-corrupt, almost-always-out-of-date algorhythm owned by somebody else, why not check out what your fellow Internet readers are marking as interesting and/or relevant? Here are three instances of the same search prototype, two with text queries and one with a from: query, showing tweets from a single person.
If you'd like to try the Twitter Seach Badge on your site, include this bit of JavaScript wherever you want it to pop up:
<script src="http://r8ar.com/tsb.js"></script>
The usual batch of configuration variables--height, width, etc--are available; to show a default search, do something like this:
<script src="http://r8ar.com/tsb.js">{"query":"obama"}</script>
<script src="http://r8ar.com/tsb.js">{"query":"from:scobleizer"}</script>
Right, obviously I need to combine this with Twitterati. I'm just wishing the Twitter Search API had a way to come up with the most recent tweets by friends of username. Will probably have to munge something together with Pipes to do that.
Also still to come: Get More and Go Back links at the bottom.
Here's my talk from the May 9th BayJax meetup, tracing the development process of this badge, which I wrote in a single afternoon. An older but much more detailed version of this presentation is online here, under Case-Hardened Web Badges: The Live Version.
Start Presentation in New Window
If you'd like me to present this, or something like it, or something completely unlike it (like Ajax security or OAuth or rolling your own API with Pipes) at your conference, please contact me and I'll see what I can do. As always, have fun and please let me know how it goes.
It is sending this for the query...
search.twitter.com/search.json?rpp=10〈=en&q=riegel&callback=yagznpalbwziotpy.p[0]
And in Safari the callback is failing with...
TypeError: Result of expression '[0]' [0] is not a function.
var id = trueName + '.p' + n;
$.w[id] = function(r) {
$.f.removeScript(id);
$.f.renderSearch(r);
};
var url = 'http://search.twitter.com/search.json?rpp=' + $.a.count + '&lang=en&q=' + encodeURIComponent($.s.q.value) + '&callback=' + id;
In edge cases where you fire off multiple searches and one comes back early, it's anybody's guess whether the callback will remember the correct ID of the script tag it needs to remove. Really wish we had those square brackets back....
I am not sure if I have introduced any other problems with this modification. Here it is...
var id = trueName + '.p'+n;
$.p = function(r) {
$.f.removeScript(id);
$.f.renderSearch(r);
};
var url = 'http://search.twitter.com/search.json?rpp=' + $.a.count + '&lang=en&q=' + encodeURIComponent($.s.q.value) + '&callback=' + trueName + '.p';
It is sending this for the query...
search.twitter.com/search.json?rpp=10&lang=en&q=riegel&callback=yagznpalbwziotpy.p[0]
And in Safari the callback is failing with...
TypeError: Result of expression '[0]' [0] is not a function.
I actually just created a Twitter Search Badge/Widget -- except it doesn't have a search field built in, it's a static search. You can check it out here: http://twitstat.us
I'll play around with this to see what things I can build.