我已成功发布到 Facebook 墙,但我希望用户可以选择是否要将其发布到某个特定的 friend 列表,例如熟人、家人等
我的代码出现了这个错误:
{"error":{"message":"(#100) privacy must contains a valid privacy 'value'","type":"OAuthException"}}
我已经添加了“privacy”属性并赋予它“Family”的值,但是它不起作用,但是如果我删除了privacy属性,墙贴就成功了
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();
}
最佳答案
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.
试试这个,但你需要知道 Family 的好友列表 ID。
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());
关于android - 使用 Facebook android SDK 发布到 Facebook 特定的好友列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8879366/