لدي هذا الكود جزء من فورم ، يقوم بارسال الروابط الى الايمايل
الفورم الحالي يقبل الروابط الذي تبدأ ب
وأنا أريد أن أحدد له قائمة من الروابط المختلفة ، اذا وجدت يرسل الفورم
<?php
$link = mb_convert_encoding($_POST['link'], 'HTML-ENTITIES', 'UTF-8'); ;
function file_get_contents_curl($url)
{
$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;
}
if(!empty($link))
{
if(strpos($link,'
https://www.facebook.com /') !== false) { // getting link content ( run function ) $html = file_get_contents_curl($link);
// parsing begins here:
$doc = new DOMDocument();
@$doc->loadHTML($html);
$metas = $doc->getElementsByTagName('meta');
for ($i = 0; $i < $metas->length; $i++)
{
$meta = $metas->item($i);
if($meta->getAttribute('property') == 'og:title')
$title = $meta->getAttribute('content');
if($meta->getAttribute('property') == 'og:image')
$image = $meta->getAttribute('content');
}
$json['statu'] = 'yes';
$json['title'] = $title;
$json['image'] = $image;
$json['link'] = $link;
}
else
{
$json['statu'] = 'link_error';
}
}
else
{
$json['statu'] = 'no';
}
echo json_encode($json);
?>