1require_once('OpenGraph.php');
2
3 $graph = OpenGraph::fetch($url);
4/*
5 echo "<br>" . "Title: " . $graph->title . "<br>"; // Getting started with Facebook Open Graph
6 echo "Site name: " . $graph->siteName . "<br>"; // YouTube
7 echo "Description: " . $graph->description . "<br>"; // Originally recorded at the Facebook World ...
8 echo "Canonical URL: " . $graph->url . "<br>"; // http://www.youtube.com/watch?v=P422jZg50X4
9 echo "Image Url: " . $graph->image . "<br>";
10 // Images
11 $image = $graph->images[0];
12 echo "Image[0] URL: " . $image->url . "<br>"; // https://i1.ytimg.com/vi/P422jZg50X4/maxresdefault.jpg
13 echo "Image[0] height: " . $image->height . "<br>"; // null (May return height in pixels on other pages)
14 echo "Image[0] width: " . $image->width . "<br>"; // null (May return width in pixels on other pages)
15
16 // Videos
17 $video = $graph->videos[0];
18 echo "Video URL: " . $video->url . "<br>"; // http://www.youtube.com/v/P422jZg50X4?version=3&autohide=1
19 echo "Video height: " . $video->height . "<br>"; // 1080
20 echo "Video width: " . $video->width . "<br>"; // 1920
21 echo "Video type: " . $video->type . "<br>"; // application/x-shockwave-flash
22*/
23 var_dump($graph->keys());
24 var_dump($graph->schema);
25 foreach ($graph as $key => $value) {
26 echo "$key => $value" . "<br><br>";
27 }
28/* // more mods
29 $graph = OpenGraph::fetch($url);
30 echo '<img src="'. $graph->image.'" width="25%" height="25%"/>';
31 echo "<br>".$graph->title . "<br>";
32 // echo "Site name: " . $graph->siteName . "<br>";
33 echo "<br>" . $graph->description . "<br>";
34*/
35
36
37https://github.com/scottmac/opengraph
38alts https://ogp.me/