Possible Duplicate:
Posting Photo to facebook fan page via iOS app by regular non-admin users
If I use the fan page id instead of uid, it will be uploaded to my own profile. I think it is due to an access token error. When I install it to the fan page, it returns a picture id, but i cannot find it anywhere - very interesting. Is there a way to accomplish what I am trying to do ?
Here is what I have attempted so far,
$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);