A OpenGraphNET is a simple parser / library for the Open Graph protocol created by Facebook. More information on this protocol can be found at opengraphprotocol.org.  If this is something new to you, I’d suggest reading up on the semantic web, RDFa, and related OpenGraph materials – there is a good writeup here covering all of the previously mentioned topics from a developer’s perspective.

On to the library… The initial implementation of OpenGraphNET was really just to get the ball rolling since no libraries currently exist for OpenGraph in .NET.  It currently can parse OpenGraph data found in HTML pages, write OpenGraph data as meta tags, and download the OpenGraph protocol schema.   However, I need to research RDFa libraries in .NET to create a more correct implementation. 

The current source code and project can be viewed at http://opengraphnet.codeplex.com/ (although I haven’t yet pushed out a recommended release).

Reading OpenGraph objects
It currently uses MSDN’s SGML parser to read HTML from a given URL, converts it to XML, and then finds all the META properties of the webpage.

//sample reading
OpenGraphObject ogObject = OpenGraphLib.PopulateOpenGraphObject("http://www.rottentomatoes.com/m/10011268-oceans/");

Writing from OpenGraph objects

Once you have an OpenGraph object populated with information, you can output it as HTML in the form of a string.

//sample output of html meta tags
OpenGraphLib.CreateOpenGraphHtml(ogObject);

Screenshot

There is much to be done for this library, but I think it is a starting point.

As for the protocol itself, there is still much debate about it, its future, the (in)valid “property” attribute of the meta tag, and of course many opinions on Facebook’s real reasoning for the protocol. Though, since it is backed by Facebook, I don’t see it going away.

  • http://tobyinkster.co.uk/ Toby Inkster

    In the HTML generated by CreateOpenGraphHtml, it would be nice if you could add xmlns:og=”http://opengraphprotocol.org/schema/” to the HEAD element.

  • http://blog.marcmezzacca.com/ Marc M

    Thanks for the feedback Toby, I'll be sure to add that as an option.

  • http://blog.marcmezzacca.com/ Marc M

    Actually the code in the CreateOpenGraphHtml currently just outputs the meta elements, not the HEAD tags.

    Anyway, I'll add the feature to include the HEAD tag. I realize it would be ok to include the xmlns in the HEAD element, but FB has the xmlns:og attribute string in the HTML element by default. Did you mean the HTML element?

  • http://tobyinkster.co.uk/ Toby Inkster

    Either the HTML element or the HEAD element — or indeed each individual META element, though that's a little wasteful.

  • http://%/zzyvotc3 WAYNE


    CheapTabletsOnline.com. Canadian Health&Care.No prescription online pharmacy.Special Internet Prices.Best quality drugs. Low price pills. Order drugs online

    Buy:Retin-A.Nexium.Human Growth Hormone.Synthroid.Petcam (Metacam) Oral Suspension.Mega Hoodia.Prednisolone.Lumigan.Actos.Valtrex.Zovirax.Arimidex.100% Pure Okinawan Coral Calcium.Accutane.Prevacid.Zyban….

  • http://%/zzeonrc5 BRAD


    NEW FASHION store. Original designers collection at low prices!!! 20 % TO 70 % OFF. END OF SEASON SALE!!!

    BUY FASHION. TOP BRANDS: GUCCI, DOLCE&GABBANA, BURBERRY, DIESEL, ICEBERG, ROBERTO CAVALLI, EMPORIO ARMANI, VERSACE…

  • http://%/zzyemzr8 LONNIE

    abilify side effects in children

    Buydrugs without prescription…

  • http://%/zzdsgqw4 CLYDE

    Cialis UK

    Buygeneric meds…

  • http://%/zzsdcuv4 EUGENE

    Advair@official.site” rel=”nofollow”>.

    Buynow it…

  • http://%/zzkrjtt1 SERGIO

    aloe@vera.gel.indicatii” rel=”nofollow”>…

    Buygeneric drugs…

blog comments powered by Disqus