您好我使用cURL帖子来抓取Facebook网址。问题是,当我在www.twingoo.ro等域名页面上使用它时,它无法正常工作。我收到此错误:
{"error":{
"type":"Exception",
"message":"Could not retrieve data from URL.",
"code":1660002
}}
当我在链接上的网站副本上使用相同的代码时:www.websoftit / twingoo.ro /它显示正确的答案而没有收到该错误,我不明白为什么:(
{"url":"http:\/\/twingoo.ro\/profil.php?user=53",
"type":"website",
"title":"Stan Elena",
"image":[{"url":"http:\/\/twingoo.ro\/images\/users\/53\/Hydrangeas.jpg"}],
"description":"Acesta este profilul meu pe twingoo.ro, intra si voteaza-ma pentru a putea castiga un super premiu!\nTe poti inscrie si tu gratuit pe twingoo.ro alaturi de mine.\nTwingoo Social Group powered by Websoftit.ro",
"site_name":"Twingoo",
"see_also":["http:\/\/www.twingoo.ro\/"],
"updated_time":"2014-03-26T11:10:14+0000",
"admins":[{
"id":"100001307485008",
"name":"Sima Cristian Alexandru",
"url":"https:\/\/www.facebook.com\/sima.cristianalexandru"
}],
"id":"1482015648693283"
}
我的php cURL代码是:
$url = 'http://twingoo.ro/profil.php?user='.$user.'&scrape=true';
$params = array(
"id"=>$url,
"scrape"=>"true");
$ch = curl_init("https://graph.facebook.com");
curl_setopt_array($ch, array(
CURLOPT_RETURNTRANSFER=>true,
CURLOPT_SSL_VERIFYHOST=>false,
CURLOPT_SSL_VERIFYPEER=>false,
CURLOPT_POST=>true,
CURLOPT_POSTFIELDS=>$params
));
$result = curl_exec($ch);
curl_close($ch);
echo $result;
我想自动化,这是我在Facebook开发者上读到的,我应该发布它。 Facebook:通过使用" scrape = true"更加自动化POST参数。对graph.facebook.com/?id={id}&scrape=true进行POST调用,其中{id}是对象ID或对象的url。响应是一个JSON对象,其中包含为url抓取的数据。