Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/euskadi31/opengraph

A PHP 5.3+ and PHP 7.3 framework for OpenGraph Protocol
https://github.com/euskadi31/opengraph

facebook-open-graph library ogp open-graph-protocol opengraph php php53 php7 php71 php72 php73

Last synced: 26 days ago
JSON representation

A PHP 5.3+ and PHP 7.3 framework for OpenGraph Protocol

Awesome Lists containing this project

README

        

# Opengraph

[![Build Status](https://secure.travis-ci.org/euskadi31/Opengraph.png)](http://travis-ci.org/euskadi31/Opengraph)

## Test with [Atoum](https://github.com/atoum/atoum)

cd Opengraph/
curl -s https://getcomposer.org/installer | php
php composer.phar install --dev
./vendor/bin/phpunit -c phpunit.xml.dist

## Writer

```php
append(Opengraph\Writer::OG_TITLE, 'The Rock');
$writer->append(Opengraph\Writer::OG_TYPE, Opengraph\Writer::TYPE_VIDEO_MOVIE);
$writer->append(Opengraph\Writer::OG_URL, 'http://www.imdb.com/title/tt0117500/');
$writer->append(Opengraph\Writer::OG_IMAGE, 'http://ia.media-imdb.com/images/rock.jpg');

echo $writer->render() . PHP_EOL;

?>
```

Output

```html

```

## Reader

```php
parse(file_get_contents('http://www.imdb.com/title/tt0117500/'));
print_r($reader->getArrayCopy());

?>
```

Output

Array
(
[og:url] => http://www.imdb.com/title/tt0117500/
[og:title] => Rock (1996)
[og:type] => video.movie
[og:image] => Array
(
[0] => Array
(
[og:image:url] => http://ia.media-imdb.com/images/M/MV5BMTM3MTczOTM1OF5BMl5BanBnXkFtZTYwMjc1NDA5._V1._SX98_SY140_.jpg
)

)

[og:site_name] => IMDb
[fb:app_id] => 115109575169727
)