-1

这是我的连接:

window.fbAsyncInit = function () {
    FB.init({
        appId: "348044465251207",
        status: true,
        cookie: true,
        xfbml: true,
        oauth: true
    });
    FB.Event.subscribe('auth.login', function (response) {
    var credentials = { uid: response.authResponse.userID, accessToken: response.authResponse.accessToken };
        SubmitLogin(credentials);
    }, { perms: 'read_stream,publish_stream,offline_access' });




    FB.getLoginStatus(function (response) {
        if (response.status === 'connected') {
            FB.api('/me', function (response) {
                //console.log('Good to see you, ' + response.name + '.');

                mail = response.email;
                currentName = response.name;
                gender = response.gender;
                place = response.location;

                $.ajax({
                    url: "/Login/DetailsToDataBase",
                    type: "POST",
                    data: { gender: gender, mail: mail, place: place },

                    success: function (data) {
                        generalScore = data;
                        div_element = document.getElementById("userScore");
                        div_element.innerHTML = "Your score is: " + generalScore;
                    }

                });

            });
        } //end if
        else if (response.status === 'not_authorized') { alert("user is not authorised"); }
        else { alert("user is not conntected to facebook"); }

    }, { scope: 'read_stream,publish_stream,offline_access' });

    function SubmitLogin(credentials) {
        $.ajax({
            url: "/Login/FacebookLogin",
            type: "POST",
            data: credentials,
            error: function () {
                alert("error logging in to your facebook account.");
            },
            success: function () {
              //  alert("success log in facebook");
                //     window.location.reload();
            }
        });
    }

};

(function (d) {
    var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
    if (d.getElementById(id)) {
        return;
    }
    js = d.createElement('script');
    js.id = id;
    js.async = true;
    js.src = "//connect.facebook.net/en_US/all.js";
    ref.parentNode.insertBefore(js, ref);
} (document));

这是在用户 facebook 墙上发布的功能:

var params = {};
params['method'] = 'stream.publish';
params['message'] = currentName +' earn '+ score+ '$ in battelship!';
params['name'] = 'BattelShip';
params['description'] = 'let\'s see if you sucsses to break my highlight';
params['link'] = 'https://apps.facebook.com/348044465251207/?fb_source=search&ref=ts&fref=ts';
params['picture'] = 'http://www.israup.net/images/98d0808995e356818a0c016bc1a2a7cc.png';
params['caption'] = 'Try it by Yourself!';

FB.api('/me/feed', 'post', params, function(response) {
  if (!response || response.error) {
    console.log('Error occured');
  } else {
    console.log('Published to stream - you might want to delete it now!');
  }

});

它只在我的墙上发布(因为我是应用程序的管理员),但对于其他用户它说:“用户尚未授权应用程序执行此操作”

请帮帮我!!

4

1 回答 1

1

我认为您需要再次查看登录文档,您在登录流程“perms”的一部分中使用了一个参数,该参数在一年前已被弃用以支持“范围”-

检查 SDK 附带的示例并阅读登录文档,尽管如果您修复了该错误,代码可能会正常工作,但我会警惕 API 中的其他内容发生了哪些变化,因为您正在使用的示例是编写的- 您可以通过使用该访问令牌调用 /me/permissions 来检查授予您正在使用的访问令牌的权限

于 2012-11-26T22:33:25.497 回答