 |
อยากทราบวิธีการดึงข้อมูลแบบ facebook พอจะมีตัวอย่างหรือแนวทางไหมครับ |
|
 |
|
|
 |
 |
|
พี่ วินครับ get_meta_tags() มันไม่สามารถget title tag ได้หรอครับ
|
 |
 |
 |
 |
Date :
2015-03-18 09:41:39 |
By :
bunchuai |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
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;
}
$html = file_get_contents_curl("http://example.com/");
//parsing begins here:
$doc = new DOMDocument();
@$doc->loadHTML($html);
$nodes = $doc->getElementsByTagName('title');
//get and display what you need:
$title = $nodes->item(0)->nodeValue;
$metas = $doc->getElementsByTagName('meta');
for ($i = 0; $i < $metas->length; $i++)
{
$meta = $metas->item($i);
if($meta->getAttribute('name') == 'description')
$description = $meta->getAttribute('content');
if($meta->getAttribute('name') == 'keywords')
$keywords = $meta->getAttribute('content');
}
echo "Title: $title". '<br/><br/>';
echo "Description: $description". '<br/><br/>';
echo "Keywords: $keywords";
ลองดูตัวนี้ครับ
|
 |
 |
 |
 |
Date :
2015-03-18 09:48:15 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากเลยครับ ทำงานง่ายเลย     
|
 |
 |
 |
 |
Date :
2015-03-18 10:10:30 |
By :
bunchuai |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|