Question

Je poste avec succès sur Facebook Wall, mais je veux que l'utilisateur puisse choisir s'ils souhaitent le publier sur une liste d'amis spécifiques, par exemple les connaissances, la famille, etc.

Mon code donne cette erreur:

{"error":{"message":"(#100) privacy must contains a valid privacy 'value'","type":"OAuthException"}}

J'ai ajouté l'attribut "confidentialité" et lui ai donné la valeur de "famille", mais cela ne fonctionne pas, mais si je supprime l'attribut de confidentialité, le Wall Post réussit

try
        {
            Bundle parameters = new Bundle();
            parameters.putString("message", msg);
            parameters.putString("description", "Test 1");
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("value", "Family");
            parameters.putString("privacy", jsonObject.toString());
            response = Data.facebook.request("me/feed", parameters,"POST");

        } catch(Exception e) {
            e.printStackTrace();
        }
Était-ce utile?

La solution

The value field may specify one of the following strings: EVERYONE, ALL_FRIENDS, NETWORKS_FRIENDS, FRIENDS_OF_FRIENDS, CUSTOM .

The friends field must be specified if value is set to CUSTOM and contain one of the following strings: EVERYONE, NETWORKS_FRIENDS (when the object can be seen by networks and friends), FRIENDS_OF_FRIENDS, ALL_FRIENDS, SOME_FRIENDS, SELF, or NO_FRIENDS (when the object can be seen by a network only).

The allow field must be specified when the friends value is set to SOME_FRIENDS and must specify a comma-separated list of user IDs and friend list IDs that 'can' see the post.

Try this instead, but you will need to know the friendlists ID for Family.

var theFriendLists = Api.Get(`me/friendlist`);
var theFriendsListIdForFamily = theFriendLists.Select item  where list_type=="family";

JSONObject jsonObject = new JSONObject();
jsonObject.put("value", "CUSTOM");
jsonObject.put("friends", "SOME_FRIENDS");
jsonObject.put("allow", theFriendsListIdForFamily);
parameters.putString("privacy", jsonObject.toString());
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top