Using Open Graph

The Open Graph Protocol is a reasonable new ad-hoc standard for adding semantic content to web sites. Open Graph got a large boost when Facebook starting using it to encourage easy linking of preferences, etc. to better model users to increase advertising revenues (documentation). Freebase also has an Open Graph interface. For example, you can look me up on Freebase using http://graph.freebase.com/mark_louis_watson (leave off the "?html=1" to get a JSON response):
{
"id" : "0b6_g82",
"username" : "mark_louis_watson",
"name" : "Mark Louis Watson",
"link" : "http://www.freebase.com/edit/topic/en/mark_louis_watson",
"embed" : "http://www.metaweb.com/topicblocks/en/mark_louis_watson",
"picture" : "http://www.freebase.com/api/trans/image_thumb/en/mark_louis_watson",
"date_of_birth" : "1951",
"nationality" : "United States of America",
"gender" : "Male",
"profession" : "Author",
"metadata" : {
"connections" : {
"spouses" : "http://graph.freebase.com/mark_louis_watson/spouses",
"books" : "http://graph.freebase.com/mark_louis_watson/books"
}
}
}
You can get my Facebook information using my user name with the graph API: http://graph.facebook.com/markwatson314. Adding required OpenGraph markup to your web pages is simple enough; for example, I added the following to my consulting web page:
    <meta property="og:title" content="Mark Watson: Ruby and Java Consultant" /> 
<meta property="og:type" content="consulting" />
<meta property="og:url" content="http://markwatson.com/consulting/" />
<meta property="og:image" content="http://markwatson.com/pictures/Mark_hat_small.jpg" />
There are other per-page attributes that you can optionally set.

There is a nice web app on Heroku that lets you check your meta data; for example: http://ogit.heroku.com for my consulting page.

How does Open Graph compare to RDFa? RDFa is a much richer notation for at least two reasons: semantic markup can refer to elements on a web page and not the entire page, and you can use any Ontology in RDFa. Still, in my opinion, any semantic markup is a good thing.

For most web applications you really want to add Open Graph and RDFa markup automatically for data driven web pages. You might as well use both because even though it takes some effort, providing semantic markup may have a long tail of benefits.

Comments

Popular posts from this blog

Ruby Sinatra web apps with background work threads

My Dad's work with Robert Oppenheimer and Edward Teller

Time and Attention Fragmentation in Our Digital Lives