如何使用 facebook API 到 post 到我自己的页面

How to use facebook API to post to my own page

我有能力 post 从我的网站到我的页面前一段时间,似乎对 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);
                }
            });
        }
    });

是的,就像错误消息所暗示的那样,这在一段时间前发生了变化。请参阅相应部分

Custom Link Page Post Image

在文档中获取更多信息:https://developers.facebook.com/docs/graph-api/reference/v3.3/page/feed

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