每個頁面負載上的Facebook API訪問令牌更改是否正確?每個頁面負載上的Facebook訪問令牌更改
我以爲一旦獲得了一個令牌,它就會一直保持不變,直到到期。
我正在使用Facebook SDK for Javascript。
Facebook表示,使用此SDK,不需要手動管理訪問令牌。 SDK只是做它。
但是每個頁面上的標記更改是否正確?
我的代碼是這樣的:
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'xxxxxxxx',
status : true,
xfbml : false,
cookie : true
});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function check() {
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
// the user is logged in and has authenticated your
// app, and response.authResponse supplies
// the user's ID, a valid access token, a signed
// request, and the time the access token
// and signed request each expire
console.log(response);
var uid = response.authResponse.userID;
var accessToken = response.authResponse.accessToken;
} else if (response.status === 'not_authorized') {
// the user is logged in to Facebook,
// but has not authenticated your app
console.log(response);
} else {
// the user isn't logged in to Facebook.
console.log(response);
}
});
}
</script>
<span onClick="check()">test</span>
感謝您的測試。我發現如果在init()上將參數'status'設置爲false,它不會改變。這樣或那樣,我同意我們可能不需要擔心。 – Eduscho