OK, first of all, you cannot upload and tag photos at the same time. First you need to upload a photo, and then mark it. So the code will be
$args = array('message' => 'Testing photo tagging');
$args['image'] = '@' . realpath($FILE_PATH);
$data = $facebook->api('/me/photos', 'post', $args);
then we have to tag users in the image, but I found that I cannot tag more than one friend at a time, so I had to iterate over the array. Another thing is that the value of X and Y in the tag array is not px, its percentage value, so that these values do not exceed 100
$photo_id = $data['id'];
$tags = array(
array(
'tag_uid' => 1337904214,
'tag_text' => 'Joy',
'x' => 50,
'y' => 30
),
array(
'tag_uid' => 709019872,
'tag_text' => 'test',
'x' => 100,
'y' => 100
)
);
foreach($tags as $t) {
$t = array($t);
$t = json_encode($t);
try {
$facebook->api('/' . $photo_id . '/tags', 'post', array('tags' => $t));
} catch (Exception $e) {
print_r($e);
}
}
Good luck
source
share