我目前正在开发一个页面,可以将管理员从画廊上传所选照片到Facebook粉丝页面。使用CURL将照片上传到Facebook
我正在使用CURL上传照片Facebook粉丝页。但是,我遇到了一个重大的错误,我无法找到使用Google的解决方案。
{ “错误”:{ “消息”: “(#114)的ID必须是有效的ID字符串(例如, \” 123 \ “)”, “类型”: “OAuthException”,”代码“:114}}
这是我做post请求的函数。请求URL是如下,其中有一个有效的扇页ID和其粉丝页面访问令牌(我可以使用GET通过的file_get_contents()成功获得粉丝页面数据) https://graph.facebook.com/289113764493682/photos/?access_token=XXXXXXXXXXXXXXXXXX
function do_post_request($url, $data, $files = null)
{
// echo '<pre>';echo $url;echo '</pre>';
$file = current($files);
// post information is rebuilt
$data = array_merge($data, array('source' => '@' . $files[0]));
// init and configure curl
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
// finally, send
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
我使用本地主机测试我的代码。暂时我没有远程服务器。 我应该知道问题出在哪里?