Reputation: 17530
My code dont works, the upload is done properly but tagging is failed :(
It shows fatal error: Uncaught OAuthException: (#121) Invalid photo id thrown
$facebook->setFileUploadSupport(true);
$album_details = array(
'message'=> 'Description',
'name'=> 'Name'
);
$create_album = $facebook->api('/me/albums', 'post', $album_details);
$photo_details = array(
'message'=> 'Photo Description',
'tags'=> makeTagArray($friendsID),
);
$photo_details['image'] = '@' . realpath('img/'.$img_name);
// $upload_photo = $facebook->api('/'.$create_album['id'].'/photos', 'post', $photo_details);
$upload_photo = $facebook->api('/'.$create_album['id'].'/photos?access_token='.$facebook->getAccessToken(),'post', $photo_details);
function makeTagArray($userId) {
foreach($userId as $id) {
$tags[] = array('tag_uid'=>$id, 'x'=>$x,'y'=>$y);
$x+=50;
$y+=50;
}
$tags = json_encode($tags);
return $tags;
}
Other necessary info
'req_perms' => 'publish_stream,status_update,user_photos'
I also tried this but did not worked, it shows data[]
$x=5;
$response='';
for ($i=0;$i<count($friendsName);$i++)
{
$post_url = "https://graph.facebook.com/".$upload_photo['id']."/tags/".$friendsID[$i]."?access_token=".$facebook->getAccessToken()."&x=".$x."&y=80&method=POST";
$response = $response.file_get_contents($post_url);
$x = $x + 53;
}
Examle $post_url for a single person, then i run this in a loop for all the persons
https://graph.facebook.com/Pic_ID/tags/620949133?access_token=Access_Token|2.AQDOMdHNge0UCXG6.3600.1307613600.1-100001916529381|lCYzRYy9YPJvy1WBqkuoGVWvd50&x=5&y=80&method=POST
Shows
{
"error" : {
"type": "OAuthException",
"message": "An access token is required to request this resource."
}
}
i've changed some value intentionally
Upvotes: 2
Views: 3999
Reputation: 321
I don't know if this is possible but you can give it a try. Try first to upload the Photo. Then get the picture's ID from the uploaded photo and then add the tags to the uploaded photo.
Upvotes: 0
Reputation: 893
To make the request you need to image id in facebook and the user id. Post to either PHOTO_ID/tags?to=USER_ID or PHOTO_ID/tags/USER_ID, with the X & Y co-ordinates as variables.
See the official documentation here (http://developers.facebook.com/docs/reference/api/photo/) for more guidance.
Upvotes: 0