1

错误地,我从我的帐户中删除了我的应用程序,这当然禁用了访问令牌。我一直按照 Facebook 的 Authentication Doc 页面中的步骤获取新的访问令牌,最终成功但无济于事;访问令牌,实际上我生成的几个令牌不起作用。

有人可以提供一些方向吗?

4

1 回答 1

0

如果您使用的是 javascript SDK - 这是您的最佳路径:

    <div id="fb-root">
</div>
<script type="text/javascript">
    (function () {
        var e = document.createElement('script'); e.async = true;
        e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
        document.getElementById('fb-root').appendChild(e);
    } ());

    window.fbAsyncInit = function () {
        FB.init({ appId: 'YOUR_APP_ID',
            status: true,
            cookie: true,
            xfbml: true,
            oauth: true
        });

        FB.getLoginStatus(function (response) {
            if (response.status === 'connected') {
                var uid = response.authResponse.userID;
                //you access token is right below
                var accessToken = response.authResponse.accessToken;
                console.log('connected and allowed');
            } else if (response.status === 'not_authorized') {
                console.log('connected but not allowed');
                top.location.href = "https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=YOUR_RETURN_URL&scope=user_photos,publish_actions";
            } else {
                // the user isn't even logged in to Facebook.
                top.location.href = "https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=YOUR_RETURN_URL&scope=user_photos,publish_actions";
            }
        });
    };


</script>
于 2011-12-23T01:51:13.700 回答