目标用户尚未授权此操作facebook graph api

时间:2012-12-03 14:01:38

标签: facebook-graph-api facebook-javascript-sdk

我正在尝试代表应用程序在用户墙上发帖。

这就是我在做什么。

首先,我从facebook connect获取用户access_token,然后使用以下调用接收extended access token

https://graph.facebook.com/oauth/access_token?             
  client_id=APP_ID&
  client_secret=APP_SECRET&
  grant_type=fb_exchange_token&
  fb_exchange_token=EXISTING_ACCESS_TOKEN 

现在,当我尝试使用以下代码在朋友墙上发帖时。

        var params = {};
        params['message'] = 'Check out this new gag I\'ve posted about you surely it will piss you off :p';
        params['name'] = 'Gagsterz';
        params['description'] = 'If you also want to have fun on gagster join in now.';
        params['link'] = 'http://localhost/php/backup/View/Profile.php';
        params['picture'] = thumbpath;
        params['caption'] = 'Caption';


        FB.api('/'+victimid+'/feed?access_token="ACCESS_TOKEN", 'post', params, function(response) {
          if (!response || response.error) {
             var json = $.parseJSON(response.error);
             alert(json.code);
        alert(JSON.stringify(response.error));
          } else {
            alert('Published to stream - you might want to delete it now!');
          }
        });

它会出现以下错误。

 the target user has not authorized this action facebook graph api
 with code 200.

我获得了权限publish_stream,我通过恢复权限进行了测试,然后登录再次授予权限,登录窗口要求post on behalf权限。但是我正在接受权限。第一次检索访问令牌。我是否必须再次获得扩展访问令牌的权限?如果是,那该怎么办?

1 个答案:

答案 0 :(得分:1)

检查您的权限,您是否有权在墙上发布。默认情况下,您将只具有读取权限。

选中此http://developers.facebook.com/docs/reference/rest/stream.publish/