See opengraphprotocol.org for an explanation of what Open Graph Protocol is.
I've created three different Open Graph Protocol parsers.
Latest version: 20110224 (ZIP) (Bzip2)
Copy OpenGraphNode.php and the "arc" folder to your web server.
Requires PHP 5+. (Version 20100427 supports PHP 4.x.)
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";
}
# 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();
Choose your favourite of:
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>.
| Name | Last modified | Size | Description | |
|---|---|---|---|---|
| Parent Directory | - | |||
| ogp-20110224/ | 2011-02-24 23:44 | - | ||
| ogp-20110224.zip | 2011-02-24 23:45 | 136K | ||
| ogp-20110131.zip | 2011-01-31 11:00 | 136K | ||
| ogp-20100427.zip | 2010-04-27 21:23 | 134K | ||
| ogp-20110224.tar.bz | 2011-02-24 23:45 | 72K | ||
| ogp-20110131.tar.bz2 | 2011-01-31 10:59 | 72K | ||
| ogp-20100427.tar.bz2 | 2010-04-27 21:23 | 72K | ||