Cover page images (keys)

From Facebook to FOAF and Back Again

Harry Halpin, University of Edinburgh and W3C Fellow
University of Edinburgh
March 2009

The Problem

Opening the Social Graph

Users and developers want to stop having to re-invite their friends. facebook pic

Users are increasingly wanting more and more powerful applications to access their social data - and having that data behind a firewall just won't do in 2008.

The to the rescue.. Danny Ayer's Video

Two Stories

Social Data Portability requires:
  1. The Social Graph Story: How do we actually get the social graph, merge social graphs from different services, and query graphs. RDF has the best story, with lots of tested software implementations
  2. The Authentication Story: How can you use a single login to securely access multiple services, both to download, modify, and upload social data? OpenID is the best story with an upswing in implementation

data portability

A Rose by another Name

For example...


Except using OpenID to access the file system and transporting data around in JSON...actually, quite similar to SPARQL minus OpenID!

RDF already a perfect file format for data transfer issues!

Work needed to be done to integrate OpenID into the Semantic Web stack!

And not enough research and working, running code around on the Web to convince development community that the Semantic Web is the way to go!

Virtual Schizophrenia

ClaimID: Your data is spread throughout the online world...and mostly not under your control


Myspace, Facebook, and OpenSocial

Similar to "browser wars," there now are competing ways to share social graph data on the Internet.

  1. OpenSocial Alliance: Started by Google and Myspace, and endorsed by Yahoo! and virtually all the minor players in the social networking world. Open Source implementation: Shindig
  2. Facebook: The dominant player in the social networking world, has mysterious plans to offer "Facebook" connect. Microsoft has a large amount of shares in Facebook.

Obviously a Semantic Web compatible standard way of doing this would be ideal.

The State of Play


Issues with OpenSocial

At first it was released had standardized input and output in Atom, and so could be easily converted to RDF.

But in later versions has more and more become a standardized API for widget applications and not for end-users to control and access their data.

Has accessibility issues as pure REST API is mixed up wth Javascript.

Has accessibility issues as pure REST API is mixed up wth Javascript.

See Shindig OpenSocial open source implementation.

Social Networking: Microformats?

More and more sites are allowing their social data to be available in microformats...

Microformats are centralized data formats for different types of data, often (nearly) isomorphic to already widely adopted non-Web standards:

What is VCard?

VCard (RFC2445):

ORG;CHARSET=utf-8:University of Edinburgh
FN;CHARSET=utf-8:Harry Reeves Halpin
ADR;CHARSET=utf-8:;;2 Buccleuch Place;Edinburgh;Scotland;;UK

vcard screen shot

Make your own VCard using this web-form maker!

What is hCard?

hCard = vCard in HTML

<table border="1">
<span class="fn n">
<span class="given-name">Harry</span>
<span class="additional-name">Reeves</span>
<span class="family-name"> Halpin</span>
<tr><td><span class="tel">+44-131-650-4421</span></td></tr>
<div class="adr">
<tr><td><span class="street-address">2 Buccleuch Place</span></td></tr>
<tr><td><span class="locality">Edinburgh</span></td></tr>
<tr><td><span class="postalcode">EH8 9LW</span></td></tr>

Make your own using hCalendar creator

Why hCard?

Microformats Logo

hCard and other microformats have shared tools, knowledge, process...

Demo of Microformat Browsing using Tails

What is XFN?

XFN, "XHTML Friends Network"

The earliest microformat, used to describe social relationships

XFN quick reference
relationship categoryXFN values
friendship (at most one): friend acquaintance contact
physical: met
professional: co-worker colleague
geographical (at most one): co-resident neighbor
family (at most one): child parent sibling spouse kin
romantic: muse crush date sweetheart
identity: me
    <li class="vcard"><a href="" class="url fn"
    rel="met collegue">Pat Hayes</a></li>
      <li class="vcard"><a href="" class="url fn"
    rel="met collegue friend">Dan Connolly</a></li>
    rel="met friend">Tom Heath</a></li>
      <li class="vcard"><a href="" class="url fn"

Deployed by quite a few sites, usually in conjunction with hCard

  1. Dopplr
  2. Last.Fm
  3. WordPress

The Limits of Microformats

Enter FOAF and the Semantic Web

FOAF: Friend of a Friend - see FOAF Project

One of the earliest and most popular Semantic Web vocabularies.

FOAF RDF markup for Person, mbox, homepage, workplaceHomepage, schoolHomepage, knows and also for things that we are in or make, like primaryTopicOf and depicts. Linked in a (semantic) Web to other FOAF files and arbitrary RDF Data. Designed to be independently extended without breaking due to using RDF technologies.

Data Portability Using FOAF


The Internals of FOAF

My hand-made FOAF is here:

	<foaf:PersonalProfileDocument rdf:about="">
<foaf:maker rdf:resource=""/>
<foaf:primaryTopic rdf:resource=""/>
	<foaf:Person rdf:about="">
<foaf:name>Harry Halpin</foaf:name>
<foaf:title>Mr. </foaf:title>
<foaf:givenname>Harry </foaf:givenname>
<foaf:homepage rdf:resource=""/>
<foaf:weblog rdf:resource=""/>
<foaf:workplaceHomepage rdf:resource=""/>
	<foaf:image rdf:about="">
<foaf:depicts rdf:resource=""/>
<foaf:schoolHomepage rdf:resource=""/>
<foaf:phone rdf:resource="tel:(44)-0-131-650-4421"/>
gcs/gp>go d-- s++,s- a- c++ ul++ p++ L++ E+ W+++ N o-- K- w--- O M- V? PS++ PE-- Y++ PGP++ t+ 5? X++ R+ !tv b+++ DI++ D+ G e+++>e++++$ h* r z+
<rdfs:seeAlso rdf:resource=""/>
<foaf:name>Paolo Bouquet</foaf:name>
	<foaf:Person rdf:nodeID="IanDavis">
<foaf:name>Ian Davis</foaf:name>
<foaf:name>Dan Connolly</foaf:name>
<rdfs:seeAlso rdf:resource=""/>
<foaf:homepage rdf:resource=""/>


Getting Started with FOAF

You can create a FOAF file with
FOAF-o-matic. There are already great tools out there, like foafnaut.

Check out Alexander Passant's marvelous mash-up of FOAF and Google Maps.


Mixing VCards and FOAF

FOAF and VCard share some overlapping properties, such as nicknames.

They do names a bit differently, with VCard splitting names while FOAF doesn't

Just convert VCard to RDF, as in the new VCard ontology.

Some of VCard may be get brought into a future version of FOAF.

hCard can be GRDDL'ed into RDF as well.

Batch convert VCard to FOAF at:

Mixing XFN and FOAF

One can convert XFN over to FOAF, by viewing it as sub-species.

And almost all XFN properties are sub-properties of the more generic foaf:knows, so fixing can be done.

See the XFN GRDDL that converts XFN to FOAF: grokXFN

A mapping of VCard, FOAF, and XFN is available in this table.

The main issue is that FOAF uses separate URIs for people than for documents

Just breaking the Mainstream!

FOAF is natively expored by sites such as and . You can even get it off of Facebook via using this plug-in yahoo semsearch

FOAF supported in Yahoo!'s SearchMonkey

From Yahoo's Open Search Strategy - See SearchMonkey: Without a killer semantic web app for consumers, site owners have been reluctant to support standards like RDF, or even microformats. We believe that app can be web search...we plan to support vocabulary from Dublin Core, Creative Commons, FOAF, GeoRSS, MediaRSS, and others. ... we will support RDFa and eRDF markup to embed these into existing HTML pages. yahoo semsearch

And remember Microsoft just bought Powerset

Google's Social Graph API: Mixing FOAF and XFN

Brad Fitzpatrick over at Google is working on using the hCard and XFN microformats to create and track identities.

Contact Finder follows relationships and indexes whose linked to whom...

social graph demo

See Plaxo's open source Social Graph code.

Hotel Review Mash-Up: Problem

Hotel Review Mash-Up: Problem Solved

A hotel with a ranking of 5 reviewed by a trusted friend:

reviews Data in RDF query


ratingnameregion homepage hotelname
5 PeterS Edinburgh Witch's Caldron Hotel, Edinburgh

"How did you do that?"

Data Mash-Up

hotel review query answer diagram

Getting that FOAF: GRDDL

GRDDL (Gleaning Resource Descriptions from Dialects of Languages) is a way to boostrap RDF out of XML and in particular XHTML data by explicitly linking transformations from RDF to XML.

GRDDL terminology:

  1. Source Document: an XML document which references at least one GRDDL transformation and hence licenses a GRDDL-aware to extract RDF.
  2. GRDDL-aware agent: a software agent able to identify the GRDDL transformations and run them to extract RDF.
  3. GRDDL Transformation: an algorithm for getting RDF from a source document


One problem with GRDDL is that it only works with HTML...

tidying diagram

However, you can use tidy or tagsoup parser to automatically convert HTML to XHTML.

HTML 5 will include an standardized XML serialization of HTML (XHTML 5) that then lets us use GRDDL - see html5lib


Note that HTML 5 may deprecate the profile attribute used by GRDDL, in which case we can update GRDDL to use just just the typed Link attributes.

Also note that HTTP is likely adding in a Link header back into HTTP, so that GRDDL can be added to pages without touching the HTML.

Describing your Social Network

Recall Jane needs to her list of trusted sources in some machine readable format.

As long as they can be mapped to RDF, they can be mapped to each other.

Xhtml Friends Network (XFN): an XHTML profile

  1. XFN is an microformat for social network data; this profile of HTML is named with a URI.
  2. The page of Jane's friends adds one attribute to declare this profile:
<html xmlns="" xml:lang="en">
  <head profile="">
	<title>Jane's XFN List</title>
  <h1>Jane's <abbr title="XHTML Friends Network">XFN</abbr> List</h1>
  <ul class="xoxo">
    <li class="vcard"><a href="" class="url fn"
    rel="met collegue friend">Peter Smith</a></li>
      <li class="vcard"><a href="" class="url fn"
    rel="met">John Doe</a></li>
      <li class="vcard"><a href="" class="url fn"
    rel="met">Paul Revere</a></li>

* actually, the XFN profile isn't quite GRDDL-happy yet; but the eRDF profile is.

Out comes mergeable RDF data

magic* happens here...

@prefix rdf: <> .
@prefix foaf: <> .
@prefix h: <> .
@prefix xfn: <> .

    foaf:homepage <>;
    xfn:friend [
        foaf:homepage <>
    xfn:met [
        foaf:homepage <>
    ], [
        foaf:homepage <>
    ], [
        foaf:homepage <>
    ] .

Using a GRDDL Transformation Directly

The hReview microformat doesn't have an established profile yet, so the Hotel Review data uses GRDDL directly:

<html xmlns="" xml:lang="en">
  <head profile="">
    <title>Hotel Reviews from</title>
    <link rel="transformation" 
<div class="hreview" id="_665">
  <div class="item vcard">
  <b class="fn org">Witch's Caldron Hotel, Edinburgh</b>
  <span><span class="rating">5</span> out of 5 stars</span>
  1. The transformation link tells a GRDDL-aware agent how to find an transformation, ../hreview2rdfxml.xsl from this syntax to standard RDF/XML syntax.
  2. The profile shows that this document uses rel="transformation" as specified in by GRDDL.

More precise SPARQL query

"Find reviews of hotels in Edinburgh better than 2 stars and tell me the name of the hotel and the reviewer."

SELECT DISTINCT ?name ?rating ?homepage

FROM <hotel-data.rdf>
FROM <janefriends.rdf>

?x rev:hasReview ?review;
  vcard:adr [ vcard:locality "Edinburgh" ].

?review rev:rating ?rating;
  rdfs:label ?hotelname; 
  rev:reviewer [ foaf:name ?name ].
FILTER (?rating > 2).

Sample Query Online

SPARQL results from hReview and vcard locality data

This shows hotels with a rating of 2 stars or higher that are located in Edinburgh, but there might be review spam:

rating name hotelname region
5 "RexR" "Ritchie Centre, Edinburgh" "Edinburgh"
5 "PeterS" "Witch's Caldron Hotel, Edinburgh" "Edinburgh"
5 "Simon" "Forest Cafe Youth Hostel, Edinburgh" "Edinburgh"
5 "RexR" "McRae Palace, Edinburgh" "Edinburgh"
4 "JohnD" "Walter Scott Hotel, Edinburgh" "Edinburgh"

Mashing up Friends and Hotel Reviews

Querying for Trusted Reviews

"Find reviews by my friends of hotels in Edinburgh better than 2 stars and tell me the name of the hotel and the reviewer."

PREFIX xfn: <>

SELECT DISTINCT ?rating ?name ?homepage ?hotelname
FROM <review.rdf>
FROM <xfn.rdf>
?place rev:hasReview ?review;
  vcard:adr [ vcard:Locality "Edinburgh"].
  rdfs:label ?hotelname;
  rev:rating ?rating;
  rev:reviewer ?reviewer.

FILTER (?rating > 2).

?reviewer foaf:name ?name;
  foaf:homepage ?homepage.

[ foaf:homepage <janefriends.html> ]
   xfn:friend [ foaf:homepage ?homepage ].

Details: hotelquery3.rq

Hotel query diagram

"Find reviews by my friends of hotels in Edinburgh better than 2 stars and tell me the name of the hotel and the reviewer."

hotel review query diagram

Trusted Reviews from SPARQL via GRDDL

Just right:

ratingnameregion homepage hotelname
5 PeterS Edinburgh Witch's Caldron Hotel, Edinburgh

From Data to Authentication?

We're done with the data side of the story, where the Semantic Web easily has the most mature stack.

But what about the authentication side of the story?

As easy as encrypting FOAF files? Not quite...


Log-in once. No more "I forgot more password and username"! openid

OpenID is a way of a user "logging-in once" to a service provider and then having their log-in details be verified by a trusted identity provider.

Your new OpenID username is a globally-unique URI:

a href="">

ClaimID gave can many others...

Sound familiar?

Tim Berners-Lee: "The AWWW says that everything of importance deserves a URI. Go ahead and give yourself a URI. You deserve it!"

How does OpenID work?

  • Service Provider fetches HTML from User OpenID URI to discover identity provider.
    <meta http-equiv="X-XRDS-Location" content="" />
    <link rel="openid.server" href="" />
    <p>OpenID identity page for hhalpin</p>
  • Establishes shared secret code with identity provider, using Diffie-Hellman key exchange.
  • Redirects the user to the identity provider
  • If user can log-in or is already logged in, the user is redirected back with their identity verified.
  • See this great OpenID tutorial, from which we took this list and other details: Just the start - and Yahoo now has an OpenID for everyone of their users, and Mozilla and Microsoft have announced OpenID support.. estimated 120 million OpenID users

    Go use your OpenID (list from LifeWiki


    OAuth is a standard way for developers to offer their services via an API without forcing their users to expose their passwords or credentials. oauth

    Built in support for desktop applications, mobile devices, set-top boxes, and of course websites.

    OAuth prevents it by explicitly asking you if you want to let Facebook grab your details from the provider. While OpenID 2.0 providers (using OpenID Attribute Exchange) may hold general information about you (avatar photo, addresses, phone numbers) that it can with your consent to service providers so users don't have to re-enter profile details, it's not really extensible on a Web-scale or meant to compete with OAuth.

    Enter FOAF and RDF?

    OAuth and the Semantic Web

    Uses HTTP Headers WWW-Authenticate combined with digital signatures to authorize tokens that let one machine authorize the use of user's data on another server.

    Once you verify that someone is trusted (perhaps via OpenID), you can offer them services via handing out keys via OAuth. It's Web Services Redux with a good authentication story!

    No reason it can not be used to exchange Semantic Web Data Authorization: OAuth realm="", oauth_consumer_key="dpf43f3p2l4k3l03", oauth_token="nnch734d00sl2jdk", oauth_signature_method="HMAC-SHA1", oauth_signature="tR3%2BTy81lMeYAr%2FFid0kMTYa%2FWM%3D", oauth_timestamp="1191242096", oauth_nonce="kllo9940pd9333jh", oauth_version="1.0"

    Privacy: Rules and Proofs

    People want different levels of access and different profiles for different people.

    If all your data is stored in RDF, then you could use rules to determine what parts of it you want to release.

    Different rules for different levels of access.

    Data could carry a proof of where it's been generated, where it is supposed to go, and so on. policy

    See all this work together via SUN Microsystem's FOAF+SSL implementation.

    The Future

    semantic web There is no technical reason why the social data in your e-mail account is kept artificially separated in your mobile phone, your social networking site, blog ...

    The two questions are:

  • What will the technical solution be? (OpenID, FOAF, OpenSocial...),
  • Can the major vendors commit to one web of social data? (Can W3C help?)
  • The first easy-to-use Semantic Web application that integrates these etechnologies to let people manage their social data across real world services are going to make a large splash...

    So ask Royal Enterprise Society for some cash to fund a semantic start-up!

    Get Involved Via the W3C!


    The standards body that preserved HTML as an open standard, created XML, RDF, etc...

    The W3C is now planning on creating a Social Web Incubator Group!

    University of Edinburgh is a member, so you can join the fun

    FOAF is just one part of a picture

    Linked Data

    All Wikipedia in RDF

    is growing...

    and growing...

    and growing...

    and growing...

    and growing...

    Evolution of Web

    timbl semantic web
    1. Web 1.0 = Web of Hypertext
    2. Web 2.0 = Web of Social Networks
    3. Web 3.0 = Web of Data?