Check the social graph in the sidebar on the about page (the website has been redesigned and the sidebar has been removed now). It shows a bunch of links to websites elsewhere that are loosely related to me, my LinkedIn profile or Flickr photos for example, or websites of friends. These links are automatically collected based on XFN and FOAF data via the Google Social Graph API.
A Social Graph
A social graph consists of who and how an individual is connected to. In the internet world people use XFN and FOAF to describe their connections with other people’s websites. These websites can be my other websites (such as my Flickr photo page) or a website of a friend of mine.
The XFN examples above describe my connection to Jelle Vandebeeck’s website, a friend of mine, and my Flickr photo page. Now, I’m not the only one using this, thousands of links (blogs, LinkedIn profiles, Twitter profiles, etc.) have been marked up in this way. What if we could visualize all these online connections?
Google released the Social Graph API which crawls their index for all XFN and FOAF enabled links. Their API returns a JSON response with all these links and the connection types associated with it. Since it uses the Google index you have fast access to massive amounts of data. The correctness of the data depends on the freshness of the Google index of course. My Twitter profile link still shows up in the results even though I removed my account a few months ago and the links in my earlier blog post aren’t included yet.
Ruby on Rails Implementation
How do we build our own social graph in Ruby on Rails? You’ll need the JSON gem to parse the Google response (might be included in Rails 2, not sure).
Next, we ask Google for our social graph. This builds an array with all the pages on a webpage.
We remove the duplicates at the end and there you have it, an array with all your XFN and FOAF friends linking to the given URLs. You can play with the 3 parameters at the end of the Google URL:
|fme||true, false, 1 or 0||Follow the ‘me’ links found on the given URL.|
|edi||true, false, 1 or 0||Return a list with pages linking to the given URL.|
|edo||true, false, 1 or 0||Return a list with pages linked from the given URL.|