简体   繁体   English

Facebook API(Javascript):发布到朋友列表

[英]Facebook API (Javascript): Posting to a friendlist

Can someone point me in the right direction for publishing a post to a friendlist using the Facebook JS API? 有人能指出我使用Facebook JS API将帖子发布到朋友列表的正确方向吗? I have so far been using this code: 到目前为止我一直在使用这段代码:

    FB.api('me/feed', 'post', { message: msg,privacy: {value: "CUSTOM", friends: "SOME_FRIENDS", allow:selected_list}}, function(response) {
        if (!response || response.error) {
            console.log(response);
            console.log('ERROR ERROR ERROR');
        }
        else {
            console.log(response);
            console.log('successfully sent, now reload data');
            refreshData();
        }
    })

In this case, *selected_list* is the id for the friend list. 在这种情况下,* selected_list *是朋友列表的id。 I have also tried passing in a list of ids to post to my friends walls using a string like this: "aID,bID,c_ID,d_ID" 我也尝试传入一个id列表,使用这样的字符串发布到我的朋友们的墙上:“aID,bID,c_ID,d_​​ID”

It seems to be posting to my own wall but not to my friends walls and more important does not show up in the friendlist feed. 它似乎是张贴在我自己的墙上,但不是发布在我的朋友的墙上,更重要的是没有显示在好友列表中。 I can post comments on a feed easily but can't create new posts and have them shared among my friends within that list. 我可以轻松地在Feed上发表评论但无法创建新帖子并让他们在该列表中的朋友之间分享。

Any help would be greatly appreciated. 任何帮助将不胜感激。

The code you wrote posts to your own wall.. The API is posting to me/feed which is nothing but your own wall.. It should be FRIEND_ID/feed 你写的代码发布到你自己的墙上.. API发布给me/feed这只是你自己的墙...它应该是FRIEND_ID/feed

FB.api('/FRIEND_ID/feed', 'post', { message: body }, function(response) {
  if (!response || response.error) {
    alert('Error occured');
  } else {
    alert('Post ID: ' + response.id);
  }
});

The above code posts the message to the friend's wall with the FRIEND_ID. 上面的代码使用FRIEND_ID将消息发布到朋友的墙上。 Hope this helps. 希望这可以帮助。

Your using the deprecated format for the privacy object. 您使用已弃用的隐私对象格式。 I suspect that is your issue. 我怀疑那是你的问题。

FB.api('/me/feed', 'post', { 'message': msg, 'privacy' : {'value': 'CUSTOM',
      'allow':'uid1,uid2,flid1,flid2'}}, function(response) {

    }
});

And don't try to use spaces in your comma separated list. 并且不要尝试在逗号分隔列表中使用空格。 I spent 3 hours before figuring out that you can't do that. 我花了3个小时才搞清楚你不能那样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM