【问题标题】:(#200) The user hasn't authorized the application to perform this action(#200) 用户未授权应用程序执行此操作
【发布时间】:2012-12-13 14:33:08
【问题描述】:

我正在尝试使用他们提供的 Js 文件构建一个 Facebook 应用程序。

我可以让用户注册我的应用程序,但我必须在他们的墙上发布提要(我也不希望用户批准的预先确认消息,用户应该只登录到他/她的帐户) .

以下是代码:

<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>

FB.init({ appId: '<%: Facebook.FacebookApplication.Current.AppId %>', status: true, cookie: true, xfbml: true });
    var userName;


    FB.login(function (response) {
        //alert('1');
        if (response.authResponse) {
            var access_token = FB.getAuthResponse()['accessToken'];
            //alert('Access Token = ' + access_token);
            FB.api('/me', function (response) {
                alert('Good to see you, ' + response.name + '.');
                userName = response.name;
                document.getElementById('btnPostFeed').style.display = 'block';

            });
        } else {
            document.getElementById('btnPostFeed').style.display = 'none';
            //console.log('User cancelled login or did not fully authorize.');
        }
    }, { scope: '' });    

 function SubmitPost(msg) {
try {
    if (userName != null || typeof userName != 'undefined') {
        var wallPost = {
            message: msg + " By : " + userName,
            picture: '',
            link: '',
            name: 'test app posted in your wall',
            caption: '',
            description: ('Test description')
        };
        FB.api('/me/feed', 'post', wallPost, function (response) {
            if (!response || response.error) {
                /*action*/
                alert('Message could not be Posted.');
                alert(response.error.message);
            } else {
                /*action*/
                alert('Message Posted successfully.');
            }
        });
    }
    else {
        alert('Please wait while User Info is Loaded..');
    }
}
catch (err) { alert('SubmitPost: ' + err); }

我的主要问题是: 我得到 (#200) 用户尚未授权应用程序执行此操作

以下是应用注册的屏幕截图:

我该怎么办?

【问题讨论】:

  • 您在应用中要求什么scope?你读过Permission 文档吗?

标签: javascript facebook facebook-graph-api


【解决方案1】:

你的范围在这一行完全是空的

}, { scope: '' });

如果您没有请求正确的权限,您将不会被授权。

但我必须在他们的墙上发布提要(而且我不希望用户批准的预确认消息,用户应该只登录到他/她的帐户)。

这毫无意义,您的用户需要批准您才能在他们的墙上发帖。如果他们只登录,他们只会授予您最基本的权限,不包括在他们的墙上发帖。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多