Using the foaf:openid property

A nice feature of the foaf:openid property is that it helps to retrieve the unique foaf:Agent associated to an OpenID URI, since its an owl:InverseFunctionalProperty.

When I wrote PHOAF, I have to deal with the question of identifying who was the main subject of a FOAF profile (either a Person or a Group) in order to get links to their homepage, depiction…

In most of people’s files, thanks to foaf-o-matic, there’s foaf:PersonalProfileDocument + foaf:primaryTopic so that’s quite easy. Yet, if there’s not such property, I used this kind of rule:

Now, using the foaf:openid property and authenticating with OpenID - plus retrieving the FOAF profile associated with that URI - solves this with a single SPARQL query:

select ?who
where {
  ?who foaf:openid <openid_uri>
}

More than a way to solve people ambiguity in a profile, FOAF + OpenID also offers nice views regarding decentralized identity management. Trust an OpenID provider for authentication, but store all your personal informations in your FOAF profile.

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.