Odyss3us
Odyss3us

Reputation: 6635

Tag users in a photo uploaded to a facebook page

I am trying to upload a photo to a specific page, which is working, but now I would like to tag the current authenticated user in that photo I have just uploaded to the page.

Here is my code,

$result = $facebook->api('/PAGE_ID/photos', 'post', array(
        'source'        => '@pic.jpeg',
        'message'       => 'Ninja of the month!!!',
        'access_token'  => 'PAGE_TOKEN',
        'tags'          => array(array(
                              'tag_uid'=> CURRENT_USERS_UID,
                              'x'      => 0,
                              'y'      => 0
        ))
));

when I try that I get this error Fatal error: Uncaught OAuthException: (#322) Invalid photo tag subject thrown, I have made sure that the page allows users to be tagged, and that I have the required permissions, status_update,publish_stream,user_photos,offline_access,manage_pages.

Any idea why this could be happening and how I can fix it?

Upvotes: 0

Views: 2076

Answers (2)

Maria
Maria

Reputation: 267

I think you might need to update the tags with the different access_token (user's access_token).

something like this might work

$facebook->setFileUploadSupport(true); 
$args = array(
'access_token'  => 'PAGE_TOKEN',
'message' => 'MESSAGE',
'image'   => '@' . realpath($path_to_user),
);

$data = $facebook->api('/ALBUM_ID/photos', 'post', $args);

$token = $facebook->getAccessToken();

$argstag = array('to' => 'USER_TO_TAG');
$argstag['x'] = 40;
$argstag['y'] = 40;
$argstag['access_token'] = $token;
$datatag = $facebook->api('/' . $data['id'] . '/tags', 'post', $argstag);

Upvotes: 1

Kia Coates
Kia Coates

Reputation: 61

I think this may be a bug, I think we may be having the same problem:

http://facebook.stackoverflow.com/questions/8425605/cant-tag-users-on-facebook-page-php-sdk-graph-api

This is a link to someone who has posted the issue as a bug to facebook. I don't know if anyone is working on this but please add your vote to getting it fixed and leave a comment. I'm sure that a LOT of people would like this functionality!

http://bugs.developers.facebook.net/show_bug.cgi?id=17947

Upvotes: 0

Related Questions