Skip to content

Commit

Permalink
php blocks needed to trigger syntax highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
niallkennedy committed Nov 7, 2011
1 parent d594eef commit 8e2330a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Expand Up @@ -56,6 +56,7 @@ $audio->setType('audio/mpeg');
Declare a new `OpenGraphProtocol` object and set some properties. Add structured media objects.

```php
<?php
$ogp = new OpenGraphProtocol();
$ogp->setLocale( 'en_US' );
$ogp->setSiteName( 'Happy place' );
Expand All @@ -67,19 +68,23 @@ $ogp->setDeterminer( 'the' );
$ogp->addImage($image);
$ogp->addAudio($audio);
$ogp->addVideo($video);
?>
```

Output your OpenGraphProtocol object as HTML `<meta>` elements. Default configuration uses the `property` attribute from RDFa. Change to `name` if you prefer HTML specification compliance and consuming agents support the `name` attribute as a `property` fallback.

```php
<?php
$ogp->toHTML();
?>
```

### Global objects

Build global objects and attributes. Set time values using either an ISO 8601 formatted string or a DateTime object. DateTimes will be converted to the UTC timezone before output for consistency.

```php
<?php
$article = new OpenGraphProtocolArticle();
$article->setPublishedTime('2011-11-03T01:23:45Z');
$article->setModifiedTime(new DateTime('now', new DateTimeZone('America/Los_Angeles')));
Expand All @@ -88,19 +93,23 @@ $article->setSection('Front page');
$article->addTag('weather');
$article->addTag('football');
$article->addAuthor('http://example.com/author.html');
?>
```

Convert a global object to `<meta>` elements just as you would with `OpenGraphProtocol.`

```php
<?php
$article->toHTML();
?>
```

### Combined

A common use case might be storing Open Graph protocol objects in a Controller for use by your web application. You can add each object to an array and later iterate through the array for `<head prefix="">` and `<meta>` outputs.

```php
<?php
$ogp_objects = array($ogp,$article);
$prefix = '';
$meta = '';
Expand Down

0 comments on commit 8e2330a

Please sign in to comment.