Código PHP:
$url = "http://www.example.com";
$CodigoDelSite = file_get_contents($url);
$RegExp = "#<title>(.*?)</title>#";
$RegExp2 = "#<meta name=\"description\" content=\"(.*?)\" />#";
$RegExp3 = "#<link rel=\"image_src\" href=\"(.*?)\" />#";
preg_match_all($RegExp,$CodigoDelSite,$titlelink);
preg_match_all($RegExp2,$CodigoDelSite,$descriptionlink);
preg_match_all($RegExp3,$CodigoDelSite,$piclink);
$titlelink = $titlelink[1][0];
$descriptionlink = $descriptionlink[1][0];
$piclink = $piclink[1][0];
echo $titlelink . "<br>" . $descriptionlink . "<br>";
echo "<img src=" . $piclink . ">";
Dudas:
1- en algunos casos la meta name es igual a Description (con D mayúscula) por lo que no me la coge bien. cómo solucionarlo?
2.- muchas webs no tienen el link rel=image... por lo que no puedo traer la imagen, sin embargo en facebook lo que hacen es examinar las imágenes que contiene la web <img src=... cómo podría hacerlo?