在提供足够的文件上传权限后,照片未上传到脸谱相册中....我还提到图表api的相关问题仍然没有成功......
$facebook->getLoginUrl(array('scope' => 'user_status,publish_stream,user_photos,photo_upload,can_upload'));
$album_details = array(
'message'=> 'Testing Description For Pic',
'name'=> 'Testing Pic Album'
);
$create_album = $facebook->api('/me/albums', 'post', $album_details);
$args = array(
'message' => 'Photo from application',
'image' => '@'.$imgURL
);
$url = 'http://graph.facebook.com/'.$create_album['id'].'/photos?access_token='.$aut_key;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
$data = curl_exec($ch);
答案 0 :(得分:1)
以下是它适合我的代码
<?php
$img = 'image.jpg';
$args = array(
'message' => 'Photo from application',
'access_token'=>urlencode('Your Access token'),
);
$args[basename($img)] = '@'.realpath($img);
$ch = curl_init();
$url = 'https://graph.facebook.com/me/photos';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
$data = curl_exec($ch);
$response = json_decode($data,true);
if($response[id]>0){
// yes
}
print_r(json_decode($data,true));
print_r(curl_error($ch));
?>
可能对你有帮助。
答案 1 :(得分:0)
我遇到了同样的问题,
请尝试确保$ imgURL是服务器上的相对图片位置,而不是图片的通用网址。
另外,请尝试在此处交叉检查http://developers.facebook.com/blog/post/498/
答案 2 :(得分:0)
尝试更改
'image' => '@'.$imgURL
到
'source' => '@'.$imgURL
Facebook API指定“来源”应包含图像信息。上传图像时,图像API中没有提及“图像”字段。