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

标签 javascript facebook api privacy

我想通过 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/

相关文章:

javascript - Vue 模板中的地址标签破坏了 lint

javascript - 使用 Sharer.php 自定义 Facebook 共享

php - 无法获取评论范围

javascript - 尽管由于邻居 div 而使用 "user-select: none",Chrome 仍会复制整个 html

javascript - 为什么 JSON.parse(JSON.stringify(obj)) 删除 obj 的属性

php - 如何获得长期的 Facebook session ?

api - Zendesk API : get requester info with ticket id

php - xml php curl 请求不支持的媒体类型

javascript - JSONP 请求和 AJAX 请求有什么区别?

html - Facebook Like 按钮在 IE 中不工作