Ivo*_*San 5 php curl file-get-contents facebook-graph-api
我使用file_get_contents()获取Facebook图表api的信息
但有时我收到一个错误.
我发现必须使用cURL而不是file_get_contents().
问题是,我不知道如何将cURL与我需要传递的URL一起使用.
如果我改变了
file_get_contents($graph_url);
Run Code Online (Sandbox Code Playgroud)
进入cURL,代码是什么?
这是$ graph_url的内容
$graph_url= "https://graph.facebook.com/me/photos?"
. "url=" . urlencode($photo_url)
. "&message=" . urlencode('')
. "&method=POST"
. "&access_token=" .$access_token;
Run Code Online (Sandbox Code Playgroud)
Mau*_*ora 16
$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);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
29779 次 |
| 最近记录: |