android - 使用 Facebook android SDK 发布到 Facebook 特定的好友列表

标签 android facebook-graph-api privacy posting

我已成功发布到 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/

相关文章:

android - 带有滑动手势的运动布局 + SwipeRefreshLayout + RecyclerView 错误向上滚动的错误行为

android - 使用 gradle 编译 android 库时如何抑制警告?

android - 可以在 Google Play 上为 Android TV 和智能手机发布相同的应用程序

facebook-graph-api - 自 2013 年 2 月 6 日起通过 'feed' 连接失败使用 Graph API 发布到 friend 的墙上

ios - 定位服务 : 'Blue Bar' during 'Always' Mode

安卓模拟器报错:missing kernel file

facebook - 如何在不使用 fql 的情况下获取帖子 url 的 facebook 点赞、分享和评论计数?

java - 使 RestTemplate 处理响应正文,无论状态如何

javascript - 追踪用户的第三方 cookie 方法已经过时 - 接下来会发生什么?

facebook - 如何通过图形 API 更改发布在 Facebook 上的照片的隐私设置