可能重复:
Posting Photo to facebook fan page via iOS app by regular non-admin users
如果我使用粉丝页面ID而不是uid,它将被上传到我自己的个人资料中。 我认为这是由于访问令牌错误造成的。 当我将它安装到粉丝页面时,它会返回一个图片ID,但我无法在任何地方找到它 - 非常有趣。有没有办法完成我想要做的事情?
这是我到目前为止所尝试的内容,
$uid = $facebook->getUser();
$token = $session['access_token'];
//here I get the token from the $session array
$album_id = '35465';
$pageid="170319849651932";
/* Tried to work with likes (after accounts..) but returns not access token
$likes = $facebook->api('/me/likes');
foreach($likes['data'] as $like)
if($like['id'] == $pageid)
{ // the one we are looking for
$token = $like['access_token'];
}
*/
//upload your photo
$file= 'fight_club_020.jpg';
$args = array(
'message' => "$uid",
);
$args[basename($file)] = '@' . realpath($file);
$ch = curl_init();
$url = 'https://graph.facebook.com/'.$pageid.'/photos?access_token='.$token;
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);
$szam=json_decode($data,true);
}
$photo = $facebook->api($szam[id]);
print_r($photo);