PHP code example of brunomp / opengraph

1. Go to this page and download the library: Download brunomp/opengraph library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

brunomp / opengraph example snippets

 php

namespace Demo;

    Opengraph\RenderHtml,
    Opengraph\RenderJson;

$og = new Opengraph();
$og->addMeta(Opengraph::OG_TITLE, 'The Rock');
$og->addMeta(Opengraph::OG_TYPE,  Opengraph::TYPE_VIDEO_MOVIE);
$og->addMeta(Opengraph::OG_URL,   'http://www.imdb.com/title/tt0117500/');
$og->addMeta(Opengraph::OG_IMAGE, 'http://ia.media-imdb.com/images/rock.jpg');

echo $og->render(new RenderHtml());
echo $og->render(new RenderJson());

 php

namespace DemoParser;

ser = new ParserHtml(file_get_contents('http://www.imdb.com/title/tt0117500/'));
$opengraph = $parser->parse();
print_r($opengraph->getArrayCopy());