Toby Inkster’s Open Graph Protocol Page

See opengraphprotocol.org for an explanation of what Open Graph Protocol is.

I've created three different Open Graph Protocol parsers.

Open Graph Protocol to JSON
A RESTful web service intended for quick page testing (not large-scale/regular use).
RDF-RDFa-Parser
An RDFa parsing library for the Perl programming language. This offers shortcuts for parsing Open Graph Protocol data.
OpenGraphNode.php
A simple Open Graph Protocol parser for PHP (see below for more info).

OpenGraphNode.php

Latest version: 20110224 (ZIP) (Bzip2)

Installation

Copy OpenGraphNode.php and the "arc" folder to your web server.

Requires PHP 5+. (Version 20100427 supports PHP 4.x.)

Basic Usage

include "OpenGraphNode.php";

# Fetch and parse a URL
#
$page = "http://www.rottentomatoes.com/m/oceans_eleven/";
$node = new OpenGraphNode($page);

# Retrieve the title
#
print $node->title . "\n";    # like this
print $node->title() . "\n";  # or with parentheses

# And obviously the above works for other Open Graph Protocol
# properties like "image", "description", etc. For properties
# that contain a hyphen, you'll need to use underscore instead:
#
print $node->street_address . "\n";

# OpenGraphNode uses PHP5's Iterator feature, so you can
# loop through it like an array.
#
foreach ($node as $key => $value) {
	print "$key => $value\n";
}

Advanced Usage

# What if a page has multiple <meta property="og:title"> elements?
#
$titles = $node->title(TRUE);  # return an array
print_r($titles);

# This gets a key=>value array of all properties.
#
$all = $node->All();
print_r($all);

# And this gets a key=>array_of_values array of all properties.
#
$all = $node->All(TRUE);
print_r($all);

# The Open Graph Protocol is based on RDFa, and OpenGraphNode.php
# is powered by a full-fledged RDFa parser. You can access all
# the page's RDFa data if you like!
#
$data = $node->RDFa();

# Return the URL of the page (after following any redirections)
#
$url = $node->Base();

Author

Toby Inkster <http://tobyinkster.co.uk/>.

Licence

Choose your favourite of:

Support / Warranty

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

For support, try the OGP developers' mailing list <http://groups.google.com/group/open-graph-protocol>.


[ICO]NameLast modifiedSizeDescription

[PARENTDIR]Parent Directory  -  
[DIR]ogp-20110224/2011-02-24 23:44 -  
[   ]ogp-20100427.tar.bz22010-04-27 21:23 72K 
[   ]ogp-20100427.zip2010-04-27 21:23 134K 
[   ]ogp-20110131.tar.bz22011-01-31 10:59 72K 
[   ]ogp-20110131.zip2011-01-31 11:00 136K 
[   ]ogp-20110224.tar.bz2011-02-24 23:45 72K 
[   ]ogp-20110224.zip2011-02-24 23:45 136K 

Apache/2.4.52 (Ubuntu) Server at buzzword.org.uk Port 443