Facebook api PHP - Setting privacy of photo post to custom but shows "only me" instead of friend

418 Views Asked by At

I am trying to set the privacy of a photo. I have tagged tester 1 and specify that I would like to share this photo with just tester 2.

I have the following code:

  $privacy = array(
    'value' => 'CUSTOM',
    'friends' => 'SOME_FRIENDS',
    'allow' => 'tester 2 id',
    );

$photo = (new FacebookRequest(
$session,
'PHOTO',
'/me/photos',
array (
    'source' => new CURLFile ($location.$name),
    'message' => ($caption),
    'privacy' => json_encode ($privacy),
 )

))->execute()->getGraphObject()->asArray();

//echo '<pre>' . print_r( $photo, 1) . '</pre>';
$photo_id = $photo['id'];
 echo $photo_id;

$tags = array( array( 'tag_uid' => $friend_id, 'x' => 0, 'y' => 0 ));

// call api to tag friend to photo, with json_encoded $tags
$tag = (new FacebookRequest( $session, 'POST', '/'.$photo_id.'/tags', 
array(
'tags' => json_encode( $tags ) ) ))->execute()->getGraphObject()->asArray();

I have no included the id of tester 2 but in my app, I have the id. When I run this, on my facebook the privacy shows that only I can see it - "only me" and whoever is tagged. For tester 1, it says the privacy setting is "custom".

I am not sure what the problem is. Why it says "only me" when I have specify "custom" and a friend id.

1

There are 1 best solutions below

1
On

Yes you are right,

The privacy setting is based on that user's privacy settings.

Click Here To See

Permissions

A user access token with `user_photos` permission is required to see all photos that person is tagged in or has uploaded.

So if user 2 is tagged in a picture and also they own it, only user 1 will show up cause they are the only one who accepted the permission approval.

In order for a friend to show up I believe they would have to accept your app by logging in and accepting the permissions you are requesting in your array user_photos

Also I believe there are settings on facebook that can let them not allow people to see what they are tagged in.

You can test this theory by going into your facebook app developers.facebook.com @ Click Here

go to your app/roles Add Testers . Then have them access your application and see if you can see if they are tagged in a photo now once they have accepted.

I am not sure what will happen, but this would be the appropriate way to test it.