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.

Comments

21 Responses to “Retrieving FOAF profile from OpenID”

  1. Pascal Grouselle on September 23rd, 2007 5:26 pm

    J’arrive à me connecter via mon openid. Mais peux-tu m’expliquer comment s’articlulent Foaf et Openid ?

  2. Alex on September 23rd, 2007 5:54 pm

    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

  3. Pascal Grouselle on September 23rd, 2007 6:06 pm

    Ca a l’air de marcher ;-)

  4. Alex on September 23rd, 2007 6:08 pm

    En effet, bonne nouvelle :)

  5. http://geocities.com/rmarkwhite/ on September 26th, 2007 6:23 am

    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.

  6. Alex on September 26th, 2007 8:20 am

    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)

  7. Dan Connolly on September 27th, 2007 10:05 pm

    Nifty idea… I’ve been noodling on similar ideas for a while, but haven’t found time to do much coding.

  8. Matteo Brunati on September 28th, 2007 2:05 pm

    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 .)

  9. Casual.info.in.a.bottle » Blog Archive » Esperimenti di identita’ semantiche… on September 30th, 2007 8:25 am

    […] -> Retrieving FOAF profile from OpenID […]

  10. plugin updates at willnorris.com on October 1st, 2007 10:06 am

    […] update: I’ve also added Alexandre Passant’s nice FOAF/SIOC auto-discovery code. […]

  11. Alexandre Passant » Blog Archive » Using the foaf:openId property on October 4th, 2007 10:57 am

    […] using the foaf:openId property and authenticating with OpenID - plus retrieving the FOAF profile associated with that URI - solves this with a single SPARQL […]

  12. Got on October 19th, 2007 11:16 am

    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 ?

  13. Alex on October 21st, 2007 9:43 pm

    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 !

  14. Gautier Poupeau on November 1st, 2007 2:02 pm

    Ç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…

  15. Alex on November 5th, 2007 12:49 am

    @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.

  16. Gautier Poupeau on November 5th, 2007 11:08 am

    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é…

  17. Charles Nepote homepageblog on January 4th, 2008 4:12 am

    Allons-y de notre petit test (avec une page de délégation)….

  18. Alex on January 4th, 2008 9:41 am

    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.

  19. Wordpress, FOAF, OpenID - updated : Alexandre Passant on January 6th, 2008 2:09 pm

    […] an update of my previous experiments on retrieving FOAF profiles when users authenticate a wordpress blog with […]

  20. Dirk-Willem van Gulik on January 28th, 2008 9:07 pm

    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.

  21. Alex on January 30th, 2008 11:03 pm

    Dirk-Willem> I moved to a new server and forgot to add the php5-curl library, it should be ok now

Leave a Reply

You must be logged in to post a comment.