2
votes

Facebook recently changed its publish API to prevent post on another user's wall and we should use their share dialogue.

Facebook documentation about publish

I need to share a photo to my friend's wall and I could achieve this using /USER_ID/feed post by specifying a post parameter named object_attachment. Now they have removed /USER_ID/feed post on another user's wall.

So my chances are to follow their share dialogue. But share dialogue will not accept object_attachment parameter of any kind and I can not share photo to my friend's wall or timeline.

Can any one help me?

1

1 Answers

1
votes

As you rightly mentioned, Facebook have removed the ability to post via the graph API to another user's feed.

You can, however, use their FB.ui({ method: 'feed' }) feed dialog Javascript dialog combined with target_id: to prompt the user to post to one of their friends' walls.

The accepted parameters are listed on the documentation page and no, you can't attach anything.

One alternative is to create a unique resource for each photo you would have uploaded which contains open graph meta tags, with which you can describe a thumbnail (og:image and og:image:secure_url).

Another alternative is to upload the photo to the current user's album, then to tag the user's friend in that photo:

//Tag friend_to_tag_id at position (x_coordinate, y_coordinate)
$post_url = "https://graph.facebook.com/"
    .$photo_id . "/tags/" . $friend_to_tag_id 
    . "?access_token=". $access_token
    . "&x=" . $x_coordinate . "&y=" . $y_coordinate . "&method=POST";
$response = file_get_contents($post_url);