Skip to content
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
Cannot retrieve contributors at this time
43 lines (39 sloc) 1.14 KB
* Example of reading Open Graph Protocol properties
* Fetches and parses an HTML, reading the Open Graph Protocol data from the page.
* Open Graph Protocol uses a subset of RDFa.
* @package EasyRdf
* @copyright Copyright (c) 2020 Nicholas J Humfrey
* @license
require_once realpath(__DIR__.'/..')."/vendor/autoload.php";
require_once __DIR__."/html_tag_helpers.php";
<title>Open Graph Protocol example</title>
<style type="text/css">
body { font-family: sans-serif; }
dt { font-weight: bold; }
.image { float: right; margin: 10px;}
$doc = \EasyRdf\Graph::newAndLoad('');
if ($doc->image) {
echo content_tag('img', null, array('src'=>$doc->image, 'class'=>'image'));
<h1>Open Graph Protocol example</h1>
<dt>Page:</dt> <dd><?= link_to($doc->url) ?></dd>
<dt>Title:</dt> <dd><?= $doc->title ?></dd>
<dt>Description:</dt> <dd><?= $doc->description ?></dd>