Retrieving FOAF profile from OpenID
Following Dan Brickley’s experiments, I’ve just setup an OpenID plug-in for this weblog, allowing anyone to register using OpenID, since users now need to register to comment.
Actually, one of the reason I installed it is that I thaught it would be an easy way to retrieve a FOAF profile for any registered user on this weblog. I’m using auto-discovery to get it from the OpenID URL. I don’t know if there’s any OpenID provider that have such a feature, but it can easilly be done if you’re delegating your OpenID to your own webpage, by adding the auto-discovery line in the header of your OpenID URL (check the source of this page if needed). BTW, WP users, here’s another plugin that helps to delegate your OpenID to your weblog.
The method I used to retrieve the profile is the following:
function fetch_foaf_profile($url) {
$html = file_get_contents($url);
preg_match_all('/<head.*<link.*rel="meta".*title="foaf".*href="(.*)".*\/>.*<\/head>/Usi', $html, $links);
if($links) {
if($foaf = $links[1][0]) {
$ex = parse_url($foaf);
if($ex['scheme']) return $foaf;
elseif(substr($ex['path'], 0, 1) == '/') {
$ex = parse_url($url);
return $ex['scheme'].'://'.$ex['host'].$foaf;
}
else return $url.$foaf;
}
}
return null;
}
Then, the profile is added to wp_usermeta table. The complete svn diff for the latest version of the plug-in is available here.
So, now that I can have FOAF profiles for users, I’ll be able to experiment the FOAF-avatar idea I had a long time ago. Other steps would be to combine people URIs with Morten Frederiksen’s FOAF output plugin (cannot find how to make it work with WP2.3) , using owl:sameAs to link users’ URIs created from this weblog to their profiles URI, and also to use it in the SIOC output plugin.
Regarding social networking Dan is talking about, I think that would be a great way answer questions as: do people commenting this blog already know themself in the SemWeb world ? Are they friends re. their FOAF profile ? re. Facebook ? Do they share interests ?
So, If you have FOAF and OpenID connected thanks to auto-discovery, I’ll be happy you try it so that I can start experimenting some of these ideas.
Update: The script now also retrieve SIOC profile if available.
Tags: foaf, gravatar, openid, rdf, social networks, socialgraph
