我正在使用 file_get_contents() 获取 facebook graph api 的信息
但有时我会收到错误。
我发现必须使用 cURL 而不是 file_get_contents()。
问题是,我不知道如何将 cURL 与我需要传递的 URL 一起使用。
如果我转换了
file_get_contents($graph_url);
进入 cURL,代码是什么?
这是 $graph_url 的内容
$graph_url= "https://graph.facebook.com/me/photos?"
. "url=" . urlencode($photo_url)
. "&message=" . urlencode('')
. "&method=POST"
. "&access_token=" .$access_token;
$graph_url= "https://graph.facebook.com/me/photos";
$postData = "url=" . urlencode($photo_url)
. "&message=" . urlencode('')
. "&access_token=" .$access_token;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $graph_url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$output = curl_exec($ch);
curl_close($ch);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)