I like to FOAF you

No, it isn’t a proposition, so get your mind out of the gutter 🙂 FOAF stands for Friend-of-a-Friend and is a RDF taxonomy capable of describing a person and his/her friend(s) in far more glory details than XFN, in fact it is a competing standard. Reading your mind, you are probably going to ask me, what is RDF? RDF (first published specs in 1999) stands for Resource Description Framework which means absolutely nothing to most people however it is often touted as the foundation for the so-called semantic web. If you want a good introductory RDF post, check out What Is RDF. A synopsis of RDF extracted from this ReadWriteWeb post Semantic Web Patterns: A Guide to Semantic Technologies

RDF is a powerful, graph-based language for declaring things, and attributes and relationships between things. In a simplistic way, one can think of RDF as the language that allows expressing truths like: Alex IS human (type expression), Alex HAS a brain (attribute expression), and Alex IS the father of Alice, Lilly, and Sofia (relationship expression). RDF is powerful, but because it is highly recursive, precise, and mathematically sound, it is also complex.

On a high level, FOAF has the following categories

  • Person’s basic information such as name, nick, title, homepage, email, surname, first name, given name, email (expressed as mbox), etc.
  • Person’s extended information such as blog, interest, project, school home page, work home page, friend(s) he knows, etc.
  • Person’s online accounts (includes instant messaging)
  • Person’s projects and groups
  • Person’s documents and images

As you can see, it allows for extensive coverage of a person’s information. If you want the full details, check out FOAF Vocabulary Specification 0.91. Assuming you have a basic knowledge of XML, let’s take a simple example to illustrate how FOAF is actually written.

<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot;
xmlns:foaf="http://xmlns.com/foaf/0.1/"&gt;

<foaf:Person>
<foaf:name>John Doe</foaf:name>
<foaf:mbox rdf:resource="mailto:johndoe@hisemailprovider.com" />
</foaf:Person>

</rdf:RDF>

The above XML snippet describes a person’s name and email, obviously John Doe is not a real name and johndoe@hisemailprovider.com is not a real email but you get the idea. Technically this describes a person, not the “me” identity as defined by XFN rel-me.

Let’s take a more slightly more complex example

<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot;
xmlns:foaf="http://xmlns.com/foaf/0.1/"&gt;

<foaf:Person>

<foaf:name>John Doe</foaf:name>
<foaf:mbox rdf:resource="mailto:johndoe@hisemailprovider.com" />
<foaf:knows>
<foaf:Person>
<foaf:mbox rdf:resource="mailto:jane.smith@hercompany.com" />
<foaf:name>Jane Smith</foaf:name>
</foaf:Person>
</foaf:knows>

</foaf:Person>
</rdf:RDF>

Basically the above FOAF says there is a person John Doe, his email is johndoe@hisemailprovider.com, he “knows” Jane Smith, and her email is jane.smith@hercompany.com. Note that “knows” does not necessarily equate to a friend, it simply means that you know someone, that person could be a friend, lover, co-worker, parent, sibling, or someone you met online but not in person, etc. For a more in-depth look at FOAF, check out XML Watch: Finding friends with XML and RDF.

Ok, now that you know how to create basic FOAF, what next. Unlike XFN / hCard / microformats, FOAF is delivered via a file separate from any HTML markup. Creating a FOAF file is not something that a Joe Blow user will ever do manually. However, if you are curious and want to play around with creating FOAF, you can use this handy tool FOAF-o-Matic. For most users, their service providers, the ones that support FOAF, will handle all the intricate details behind the scene. For example, if you have an account at MyBlogLog, you can check out their FOAF feature by appending “/foaf” to the end of your MyBlogLog member URL. If you aren’t a MyBlogLog member, here is Ken Brewster’s MyBlogLog FOAF file, http://www.mybloglog.com/buzz/members/kentbrew/foaf/, and check out his fun FOAF consuming app, picture below
Ken Brewster FOAF app

Since FOAF is a separate file, you have to link to it from a HTML page by adding the following HTML code within your <head> tag (using Kent Brewster’s FOAF URL)

<link rel="meta" type="application/rdf+xml" title="FOAF" href="http://www.mybloglog.com/buzz/members/kentbrew/foaf/&quot; />

In MyBlogLog’s case, that HTML code is added automatically to a member’s profile page. I should note that in MyBlogLog’s case, the FOAF file is publicly available without any authentication allowing any search engine to crawl and index it, in fact, this information is available through Google Social Graph API but beware that there is a current limitation with Social Graph API in that Googlebot does not crawl a FOAF file linked from an HTML page, hence not making it available for the API to parse. In Brad Fitz own words,

I just verified that the problem is the crawl coverage. Historically Googlebot hasn’t cared about FOAF because it hasn’t used FOAF, so why hit your server fetching it just to throw it away? Now that the SGAPI is using it, though, I need to ask Googlebot to go get that FOAF that I know exists but is uncrawled.

A few parting thoughts…

  • Chris Messina thinks that FOAF baking in relationship information is a fundamental flaw, I have to respectfully disagree because I think it is a key missing feature from XFN/hCard, at least when it comes to my XFN consuming app. Upon further reflection, I think I understand Messina’s concern about FOAF being potentially convoluted. It is due to the powerful recursive nature of RDF that can lead to circular references and if a FOAF parser doesn’t account for this, it can lead to infinite loops.
  • Since FOAF only has a “knows” property, it is less descriptive, hence less useful, than XFN rel values (friend, acquaintance, co-worker, neighbor, sibling, parent, child, crush, date, etc)
  • Apparently FOAF does not have properties to specify an address, e.g.
    state/province, country, city, street address, quite odd indeed. However, it can be remedied by adding VCard namespace to RDF.

  • The general vibe in the web development community is that FOAF is more complicated than XFN so it is more likely to see XFN in the wild than FOAF
  • Firefox Operator plugin does not consume FOAF information
  • FOAF information is meant for app-to-app consumption unlike XFN / hCard which are embedded in HTML. Check out this post WordPress, FOAF, OpenID – updated for a WordPress plugin retrieving FOAF profiles when users authenticate a wordpress blog with OpenID.
  • There is a recent effort, hFOAF, to combine FOAF, hCard, and XFN
Advertisements

7 Responses to “I like to FOAF you”


  1. 1 Pat Hawks May 21, 2008 at 5:46 am

    So I’m all about declaring relationships and XFN type stuff, but I think FOAF is a step in the wrong direction.
    At a time when everybody is concerned about where they’re information is and who is using it how, it seems like throwing somebody’s real name, email address, phone number, heck the speck even provides for DNA information… all without that person knowing, is that ok? Is that good for users? Where’s the benefit?

  2. 2 Bob Ngu May 21, 2008 at 6:00 am

    Pat, good question, you have raised a privacy concern that is at best nebulously defined or rather undefined. As you are probably aware, user privacy is a hotly debated topic last week, check out my post on “My data and having it my way”.

    What I didn’t say in my post is that this kind of real information should only be available via proper authorization granted by the user most likely through OAuth or similar mechanisms. So yes it is scary that some of the information is publicly available on certain sites perhaps without the users fully knowing the implications. I think such sites should state this in simple understandable language instead of just saying FOAF which means nothing to your average users.

  3. 3 Bob Ngu May 21, 2008 at 6:05 am

    Oh BTW, a subset of the information can also be exposed via hCard. By itself, hCard or FOAF can be made publicly available or available upon user authorization.

  4. 4 Alex. May 22, 2008 at 9:08 am

    Hi,

    As you said, even if most FOAF profiles are available as separate files from HTML documents (eg: user homepage), you can directly embed FOAF (actually, RDF) information in XHTML pages using RDFa.
    Check:
    http://rdfa.info
    http://www.w3.org/TR/xhtml-rdfa-primer

    Regarding the lack of precision of foaf:knows, there’s a relationship vocabulary that define more precise subproperties. Moreover, since that’s RDF, you can extend it with your own properties if needed.
    http://vocab.org/relationship/

    You may also be interested in SIOC, which allows to represent social media contributions in RDF and has mappings with FOAF to link a user to his online data:
    http://sioc-project.org

  5. 5 Bob Ngu May 26, 2008 at 10:35 pm

    @Alex, thanks for the reminder about RDFa. As for FOAF:knows, I agree that since it is RDF, I can extend with custom properties if needed but that defeats the purpose of having a standard set of properties that a parser can look for, so while it is possible, I wouldn’t use it for the reason that it isn’t standard. I am also aware of SIOC, I will probably write a post about it later.

    Thanks for dropping by my blog.

  6. 6 Stefano Bortoli March 24, 2009 at 6:43 pm

    If you need to edit a FOAF profile, you can use foaf-O-matic, at http://www.foaf-o-matic.org. It allows to load a profile from a remote location, edit it, and the upload it again in the location via SFTP. BTW, it allows also to import friends description through v-card. give a shot! 😀

  7. 7 podo July 4, 2011 at 3:10 am

    FOAF – who would think about that?:))). Great write up. THanks.


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s





%d bloggers like this: