gpt4 book ai didi

javascript - JavaScript 中的 Facebook API : how add the privacy?

转载 作者:行者123 更新时间:2023-11-29 10:49:02 25 4
gpt4 key购买 nike

我想通过 Javascript 中的 Facebook Api 在我 friend 的墙上发布帖子,但是当我在“FB.api”中插入“隐私”时,此代码无法正确运行。有人能帮我吗?谢谢。

var privacy = {value: 'CUSTOM',  friends: 'SOME_FRIENDS', allow: '{UID}'};
var privacy2 = JSON.stringify(privacy);

FB.api("/{UID}/feed", 'post', {
message: 'Message',
privacy: privacy2,
}, function(response) {
if (!response || response.error) {
alert(response.error);
} else {
alert('Message sent!');
}
}
);

最佳答案

更改隐私 JSON 以在您的 key 周围也包含引号:

var privacy={"value":"CUSTOM", "friends": "SOME_FRIENDS", "allow":"{UID}"};

FB.api("/{UID}/feed", 'post', {
message: 'Message',
privacy: privacy,
}, function(response) {
if (!response || response.error) {
alert(response.error);
} else {
alert('Message sent!');
}
}
);

但是,您似乎无法将私有(private)消息发布到其他用户的留言板上。来自privacy settings page on Facebook :

Note: The privacy parameter only applies for posts to the user's own timeline and is ultimately governed by the privacy ceiling a user has configured for an app. It does not apply to posts made by an app on behalf of a user to another user's timelines or to Pages, events, or groups. In those cases, such posts are viewable by anyone who can see the timeline or content in the group or event.

这似乎就是您收到 OAuth 错误的原因。

关于javascript - JavaScript 中的 Facebook API : how add the privacy?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13904631/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com