Show and Tell: Find Cool People on Twitter with Steve Odom’s Plum.ly

This is a guest post by friend of the Infochimps and twnty.com founder Steve Odom (@steveodom).

Several years ago, Kevin Rose launched WeFollow.com to help you find people on Twitter near you geographically with similar interests. The problem with it is you have to go to WeFollow and input your interests. It doesn’t pull your interests directly from your Twitter profile. It’s great but yet another account with data about you that you have to manage.

When Infochimps released their Twitter People Search API allowing for full text search of any twitter data field, I realized I could use it to easily build a search engine of Twitter bios, similar to WeFollow but much more powerful. Why ask users to input additional information about themselves when their twitter profile already contains lots of identifying data about them – their name, location, and whatever they say about themselves in their bio. Being able to search on this content makes for a tool like WeFollow, but one that searches every Twitter profile and not just accounts that people entered into WeFollow.

A search like that wasn’t readily available that I know of until Infochimps released their Twitter People API. I built a jazzy interface to that API and call it Plum.ly.

The initial call is just a simple jquery ajax call that’s almost too simple to list here but looks something like:

  $.ajax({ type: "GET",
    url: "http://api.infochimps.com/social/network/tw/search/people_search",
    dataType: "json",
    data: {apikey:"my-api-key", q:my_query},
    error : function(data, textStatus) {
      //error handling here if there's a problem.
    },
    success: function(data, textStatus) {
      // render the results.
    }
  });

That call returns all the names, twitter_ids and some other information for the first 100 people matching my query term. The only somewhat tricky part was converting my natural language query like “yoga in austin” or “named steve odom” into a query that knows how to look in the appropriate fields at Infochimps. I built it where there were three possible fields that could be queried – the description, location, and name fields. The sample code below converts a search like “dog lover in san francisco” into “description%3adog%20lover%26location%3asan%20francisco”, which is then used as the q parameter in the call above.

function build_query_string(str) {
	if (str.match("named")) {
		q = named_query(str);
	} else {
		q = description_query(str);
	}
	return q
}

function named_query(str) {
	str = str.replace(/named/, "")
	if (str.match("%20in%20")) {
		var spl = str.split("in%20");
		var named = "name:" + spl[0];
		var near = "location:" + spl[1];
		var q = named + "&" + near;
		q = q.replace("%20&", "&").replace(/%20/g, " ");
                //remove the last space and replace spaces with unencoded spaces.
	} else {
		var q = "name:" + str;
		q = q.replace(/%20/g, " "); //escape the encoding.
	}
	return q
}

function description_query(str) {
	if (str.match("%20in%20")) {
		var spl = str.split("in%20");
		var desc = "description:" + spl[0];
		var near = "location:" + spl[1];
		var q = desc + "&" + near;
		q = q.replace("%20&", "&").replace(/%20/g, " ");
                //remove the last space and replace spaces with unencoded spaces.
	} else {
		var q = "description:" + str;
		q = q.replace(/%20/g, " "); //escape the encoding.
	}
	return q
}

Once I started playing with searches, Michelle at Infochimps and I realized we could make it more powerful by ordering the results by each person’s trstrank. So then I could do a search like “mom blogger” and have the results ordered by the most influential mom bloggers. That’s pretty cool. The javascript code to loop through all of the Twitter People results and supplement and order them by trustrank can be found here.

A couple of more Infochimps calls and I could drill down on each person and see not just basic stuff like follow count and trstrank, but also super detailed information like all the social networks they are on (using the Qwerly API callsample code here , with whom they have the most Twitter conversations (using the Twitter Strong Links callsample code here ) and even a sample of those conversations (using the Twitter Conversations: AAtsignsB API call–sample code here). It turned out to be a great way to find very specific people (or just be nosy).

It only took me a couple of days over SXSW to build the basic functionality. Since it is essentially just calls to Infochimps and no database, a Rails app or even a Sinatra app seemed a bit of overkill. Plum.ly is simply a static html file with javascript, hosted as a Github page, and lots of calls to Infochimps.

All of the code for Plum.ly can be found at Github.

Comments are closed.