错误地,我从我的帐户中移除了我的应用程序,当然这会禁用访问令牌。我一直在关注Facebook的Authentication Doc页面上的步骤以获得一个新的访问令牌,最后取得了成功,但无济于事;访问令牌,实际上我生成的几个令牌都不起作用。
有人可以提供方向吗?
答案 0 :(得分: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>