Facebook的FB.api如何工作?

时间:2018-12-20 11:56:05

标签: javascript facebook facebook-graph-api

我是Facebook开发人员的新手。我要求通过我的应用程序在用户墙上发布帖子。但是由于publish_actions自去年8月起已弃用,因此我尝试使用FB.api方法。

我使用JavaScript SDK启动了快速设置,然后按照here. 所述的步骤进行操作 但是效果不好,我也没有收到Facebook的回复。

我错过了应遵循的任何程序吗?

此代码由facebook提供,我对此进行了尝试。

window.fbAsyncInit = function() {
  FB.init({

    appId: '/*theID*/',
    autoLogAppEvents: true,
    xfbml: false, // I'm not using social plugins, set to false
    version: 'v3.2'
  });

};

function postToWall() { //Using this function to post on the wall
  var body = 'Reading JS SDK documentation';
  FB.api('/me/feed', 'post', {
    message: body
  }, function(response) {
    if (!response || response.error) {
      alert('Error occured');
      console.log('Response: ' + response);
    } else {
      alert('Post ID: ' + response.id);
    }
  });
}

0 个答案:

没有答案