The May DIY Project from the DataPortability project is to produce and markup blocks on people's websites and blogs with XFN rel="me".

Well firstly I've already done this some time ago. On the left you'll find a block giving every profile page where I've signed up for a service. Each link is marked up with the rel="me" microformat.

As a side effect of doing this I built a small test rig for navigating round these links and links like them. I started by using Google's Socialgraph API but that works on cached data and I needed something current.

That led me to trying to find libraries in PHP for parsing Microformats. Which in turn led me to an impassioned debate on the Microformats list. The gist is that you really, really don't want to write an HTML parser in any of the more common web programming languages. To me this means that Microformats are effectively write-only data when we're talking about App to App communication. That's not to say that they aren't useful. But App to App communication needs nice elegant standards with robust and formal definitions. Which is why most of them are based on XML. Burying the data within horrible, badly written HTML by marking up visible elements is just wrong. At least for App to App communications.

However, there is still merit in marking things up with microformats because firstly it's easy to do, and secondly you can use tools like the Firefox plugin Operator to grab them. Extracting a VCard from a web page you're looking at and dropping it into your local contacts store is a great use case.

So finally we get back to XFN and rel="me". Now it turns out that if you put the html through tidy so it's well formed XML and then query the nodes, it's relatively easy to extract all the XFN entries. Here's some sample PHP5 code which uses the loadHtml() function to do the HTML Tidy for you. The source HTML has to be really bad before this fails.

$url = 'http://voidstar.com/';
if($html = @file_get_contents($url)){
$dom = new DomDocument();
if(@$dom->loadHtml($html)){
if ($nodes = $dom->getElementsByTagName('a')) {
foreach($nodes as $node){
if ($node->getAttribute('rel')=='me') {
echo $node->getAttribute('href');
}
}
}
}
}


This gives us a route into querying something like my MyBlogLog page or my Plaxo Pulse page and finding all my profile pages so I don't have to type them all in yet again to the next service (FriendFeed, say) that wants the same data.

There's a side effect of putting your YASN-Roll (Yet Another Social Network Rollcall) on your weblog. It's great for self-publicists! Why wouldn't you want your blog readers to be able to find you on Twitter, Upcoming, Facebook, Plaxo and all the other places you hang out. Which finally brings us to the last part of the DataPortability DIY project. "Adopt an Alpha Blogger". This is where we go and hand hold a well known influential blogger, encourage them to "walk the walk" and get them to build an XFN enabled YASN-Roll on their blog.

And last but not least, if you run Wordpress, you don't have to do this by hand. Stephen Paul Weber has built a plug in for wordpress that does the hard part for you as part of the DiSo project.



[ << Data Portability. An important Use Case ] [ Which XRDS contains a user's Service catalogue? >> ]
[ 03-May-08 4:15pm ] [ ]