mercredi 22 avril 2015

Facebook app: cannot post to user wall with custom privacy settings (An unknown error has occurred)

I'm working on a small Facebook app that needs to make text posts to users' walls, but with different privacy settings depending on some conditions. Everything works fine, except that when I need to post with "custom" privacy settings, the operation fails with an error code 1 and message = "an unknown error has occurred". I saw other posts talking about sessions or app tokens, etc, but I am sure none of these is the cause of my problem. I can be sure because I have made these different testings: 1. When I modify the same code, at the same spot, to making the post available with other privacy setting different that custom, this works fine. 2. When I again modify the same code keeping the custom privacy but specifying an empty string for the people allowed to view the post, it works fine setting the privacy of the post to "Only Me". 3. I have made sure of the content of the CSV String value that I pass to the command and that contains the list of friends' IDs who need to view the post. The format is correct and the IDs contained in it are also valid. When for instance I insert invalid IDs in this string, the operation succeeds and the post is published with an "Only Me" privacy level.

I really do not know what could be going wrong. Here is a snippet of the piece of code that generates the error:

$response = (new FacebookRequest( $session, 'POST', '/me/feed', array( 'message' => $message, 'privacy' => json_encode(array('value'=>'CUSTOM', 'friends'=>'SOME_FRIENDS', 'allow'=>$listOfFriends)) )))->execute()->getGraphObject();**

ListOfFriends is a CSV string that contains the IDs of the friends who should view the post. I again emphasize on the fact that this same code works with no problem when the privacy value is not CUSTOM or when it is kept CUSTOM and the string is empty or contains invalid IDs. The error occurs only when the string contains valid IDs.

I use V2.1 API.

Anyone who could help me with some clue?

Thank you very much ^^

Aucun commentaire:

Enregistrer un commentaire