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
Comments
21 Responses to “Retrieving FOAF profile from OpenID”
Leave a Reply
You must be logged in to post a comment.

J’arrive à me connecter via mon openid. Mais peux-tu m’expliquer comment s’articlulent Foaf et Openid ?
L’URL du profil FOAF est récupérée depuis la page utilisée comme identifiant OpenID, si un lien d’auto-discovery vers le profil FOAF est indiqué dans son header (comme sur ce blog, puisque j’utilise comme identifiant OpenID http://apassant.net/ et que cette page inclut un lien vers mon profil).
Malheureusement, si c’est faisable lorsque tu délègue OpenID à ton propre site, je ne sais pas si des providers OpenID offrent cette solution.
Sinon, dans l’autre sens, tu peux indiquer ton URL OpenID dans ton fichier FOAF avec la propriété foaf:openId: http://lists.foaf-project.org/pipermail/foaf-dev/2007-June/008605.html
Ca a l’air de marcher
En effet, bonne nouvelle
I tried to login using my delegated url that has a foaf autodiscovery line added but your script failed. I logged in ok but i got an error mesage about line 45 openid.php.
It should be fixed now, thanks. Could your try creating an account again ? (I removed that one, since the FOAF discovery is currently done only when creating an account)
Nifty idea… I’ve been noodling on similar ideas for a while, but haven’t found time to do much coding.
I’m using my delegation page and it works .)
Very good!!
I’l try this plugin in the next weeks in my new domain, ontriples.info .)
[…] -> Retrieving FOAF profile from OpenID […]
[…] update: I’ve also added Alexandre Passant’s nice FOAF/SIOC auto-discovery code. […]
[…] using the foaf:openId property and authenticating with OpenID - plus retrieving the FOAF profile associated with that URI - solves this with a single SPARQL […]
Ca ne marche pas du tout de mon côté que ce soit l’adresse de délégation (il ne trouve pas le serveur OpenID) qu’avec mon adresse OpenID (visiblement un problème de signature). J’ai essayé sur d’autres sites et ça fonctionne presque parfaitement (la délégation ne fonctionne pas sur le site de Dan Brickley, mais l’adresse “officielle” fonctionne et je n’ai pas besoin de créer un compte).
Aurais-je fait une erreur à un moment ou un autre ?
Il semble que l’erreur vienne d’ici. J’ai mis à jour le plug-in vers sa nouvelle version, et en effet ça plante. Après une suppression / reconfiguration, ça semble passer (en tout cas depuis un compte déjà crée).
Tu peux essayer de t’authentifier à nouveau avec ton OpenID ?
Merci !
Ça fonctionne avec mon Open ID, pas de souci, en revanche, je n’arrive pas à m’identifier avec ma page de délégation, alors qu’elle est bien configuré et qu’elle fonctionne avec mon propre site. Du coup, je ne pense pas que tu récupères mon FOAF.
Le message d’erreur indique qu’il ne trouve pas le serveur de délégation…
@Got > J’ai remarqué aussi ce problème en me connectant sur le site de son auteur, et il me semble que ça a été débuggé récemment (je n’ai pas testé ici mais j’ai la dernière version svn du plugin donc tout devrait tourner).
@Dan > The script currently finds FOAF profiles only when linked from the OpenID URL with an auto-discovery link, but indeed it would be nice if it finds it when the OpenID URL *IS* the FOAF profile w/ GRDDL.
One solution is to get the RDF and check if foaf:openId == OpenID URL, is that what you have in mind ? Or maybe, more hackish, testing the kludge you’re using (<a rel=”foaf-openid” href=”./” rel=”nofollow”>) ?
It makes me think that to be more complete, the script should check if someone in the auto-discovery file is linked to the OpenID URL with the foaf:openId property.
Ca n’a pas l’air de fonctionner avec la page de délégation, j’ai toujours la même erreur qui m’est retournée. Désolé…
Allons-y de notre petit test (avec une page de délégation)….
Ca marche
Il serait d’ailleurs temps que je mette en ligne la MAJ du code qui gère ça, puisque c’est maintenant la V2 finale du plugin wpopenid qui est utilisée ici.
[…] an update of my previous experiments on retrieving FOAF profiles when users authenticate a wordpress blog with […]
Whilst openID works - fetching a foaf gives me:
Fatal error: Call to undefined function curl_init() in /srv/d_secarret/www/apassant.net/wp/wp-content/plugins/openid/wp-openid-foaf.php on line 41
from the PHP on your end.
Dirk-Willem> I moved to a new server and forgot to add the php5-curl library, it should be ok now