需要read_page_mailboxes权限来管理对象facebook

时间:2017-08-24 03:40:13

标签: facebook facebook-graph-api

即使我已经授予“read_page_mailboxes”权限,我也遇到过来自Facebook的错误消息。

2017-08-24T03:03:03.691425+00:00 app[web.1]: POST /webhook 500 5.551 ms - 101
2017-08-24T03:03:03.790925+00:00 app[web.1]: Failed calling Send API 403 Forbidden { message: '(#200) Requires read_page_mailboxes permission to manage the object',
2017-08-24T03:03:03.790930+00:00 app[web.1]:   fbtrace_id: 'ABmbB0iwWXQ' }
2017-08-24T03:03:03.790929+00:00 app[web.1]:   code: 200,
2017-08-24T03:03:03.790928+00:00 app[web.1]:   type: 'OAuthException',

和批准项目:

enter image description here

enter image description here

我在webhook中编写了以下代码,如下所示:

router.post('/', function (req, res) {
    var data = req.body;
    if (data.object == 'page') {
        data.entry.forEach(function(pageEntry) {
            var pageID = pageEntry.id;
            var timeOfEvent = pageEntry.time;

            if (pageEntry.hasOwnProperty('changes')) {
                pageEntry.changes.forEach(function(changes){
                    if(changes.field === "feed" && changes.value.item === "comment" && changes.value.verb === "add"){
                        var messageData = {
                            message: "hello"
                        };
                        callPrivateReply(messageData, changes.value.comment_id);
                    }
                });
            }
        });
    }
});

function callPrivateReply(messageData,comment_id) {
    request({
        uri: 'https://graph.facebook.com/v2.9/' + comment_id + '/private_replies',
        qs: { access_token: 'TOKEN' },
        method: 'POST',
        json: messageData
    }, function (error, response, body) {
        if (!error && response.statusCode == 200) {
            console.log(body);
        } else {
            console.error("Failed calling Send API", response.statusCode, response.statusMessage, body.error);
        }
    });  
}

0 个答案:

没有答案