[英]check that facebook link exists using php
我有一个用户在Facebook上添加了帖子。 我想验证其链接,即图像已发布在这些链接上。 我使用curl但无法验证facebook网址,这可以通过facebook developer API或任何其他方法来实现。 谢谢
$url = 'https://www.facebook.com/photo.php?fbid=620056421410941&set=a.405109092905676.94648.100002197659601&type=1&theater';
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE);
$response = curl_exec($handle);
$httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
if($httpCode == 404) {
echo 'Not Available';
}
else
{
echo 'Available';
}
curl_close($handle);
是的,你可以做到这一点使用较轻哈克的方式..
<?php
$url = 'https://www.facebook.com/photo.php?fbid=620056421410941&set=a.405109092905676.94648.100002197659601&type=1&theater';
$handle = curl_init($url);
$agent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)';
curl_setopt($handle, CURLOPT_USERAGENT, $agent);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER , false); //<-- Add this
curl_setopt($handle, CURLOPT_FOLLOWLOCATION , true); //<--- Add this too
$response = curl_exec($handle);
if(stripos($response,'This content is currently unavailable')!==false) { //<-- Inspect the source for this text
echo 'Not Available';
}
else
{
echo 'Available';
}
curl_close($handle);
cURL
参数,如图所示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.