Hello everyone,

I am trying to find out how facebook extract information like image, title and description of a webpage using open graph tags.

Please share you knowledge or any working scripts, tutorial.


Have you any knowledge of parsing an html document with PHP or should we started it by that? If you don’t, have you tried parsing an html document, and if you did , what was the problem of extracting og tags?


Facebook does it like this.., and here is an example of an open graph if I am going to write it for Daniweb.com . Warning image url is an assumed location.

<meta property="og:title" content="Your Own Open Graph Meta Application"/>

<meta property="og:image" content="http://daniweb.com/images/daniweb_logo.jpg"/>

<meta property="og:site_name" content="Daniweb"/>

<meta property="og:description" content="An online discussion community of IT professionals. Forums to get free computer help and support."/>

To parse it, look for my previous post about 5 days back... I wrote an example on how to handle meta tags parsing..

Here are the codes I used, but you still need to read my instructions from my previous post, and adjust the url to your application... This can also work outbound and inbound through $_GET..

$url = 'http://watch32.com/movies-online/return-to-the-blue-lagoon-2766';
$file = useCurl($url);
$html = str_get_html($file);

foreach($html->find('meta[name=keywords]') as $element){
       echo $element->content.'<br/>';


echo '<br/>';
foreach( $html->find('meta[name=description]') as $desc)
$movie_detail = explode("|", $desc->content);
echo 'Title : '. $movie_detail[2].'<br/>';
echo 'Director :'. $movie_detail[3].'<br/>';

$casts= explode(",", $movie_detail[4]);
echo 'Casts<br/>';
foreach($casts as $actor){
echo $actor.'<br/>';


function useCurl($url){
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)');
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
            curl_setopt($ch, CURLOPT_AUTOREFERER, true);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            $output = curl_exec($ch);curl_close($ch);
            return $output;

This little piece of code shown below,


Should be change to


Then just iterate the array, and finally grab the result by defining which index you need.. for example


Should give you **Your Own Open Graph Meta Application **