I am trying to get title, description from external page link source. This is not working when I am trying to get Facebook page source and is returning source code of some another page. It is working on other websites like google etc. Here is my code in PHP :
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
public function previewLink(){
$url = "https://www.facebook.com/NASA/";
$html = $this->file_get_contents_curl($url);
$title = "";
$description ="";
$image = "";
//parsing begins here:
$doc = new \DOMDocument();
@$doc->loadHTML($html);
$nodes = $doc->getElementsByTagName('title');
$title = $nodes->item(0)->nodeValue();
}
I am not getting what is the problem I am facing. Can someone suggest something ? Thanks in advance.