如何使用Facebook API发布到我自己的页面

时间:2019-07-10 21:10:21

标签: facebook facebook-graph-api

前段时间,我能够从网站上发布到页面上,自那时起,当我使用以下代码片段时,似乎对API进行了一些更改

{"message":"(#100) Only owners of the URL have the ability to specify the picture, name, thumbnail or description params.","type":"OAuthException","code":100,"fbtrace_id":"AsGjV6ebkihnC60tRtHM4f3"}

代码

function postToFeed(id, desc, name) {

    var page_id = ************;
    var app_id  = ************;
    FB.api('/' + page_id, {
        fields : 'access_token'
    }, function(resp) {
        console.log(resp);
        if (resp.access_token) {
            FB.api('/' + page_id + '/feed', 'post', {
                message : desc,
                link : 'https://link',
                name : name,
                from : page_id,
                description :'',
                access_token : resp.access_token
            }, function(response) {
                if (!response || response.error) {
                    alert(JSON.stringify(response.error));
                } else {
                    alert('Post ID: ' + response.id);
                }
            });
        }
    });

1 个答案:

答案 0 :(得分:0)

是的,就像错误消息所暗示的那样,这在一段时间前已更改。参见相应部分

  

自定义链接页面帖子图片

在文档中

以获得更多信息:https://developers.facebook.com/docs/graph-api/reference/v3.3/page/feed

您当然也可以删除自定义描述参数。