0
我已經安裝了ColdFusion的Facebook的API SDK - https://github.com/affinitiz/facebook-cf-sdkFacebook OAuthException - 此授權碼已過期。 [代碼= 100]
我設置一個登錄過程,成功地不過10分鐘左右,當我返回並刷新頁面後的作品,它顯示了以下錯誤:
此授權碼已過期。 [code = 100]
有沒有我失蹤的FB登錄?我是否想要手動檢查某些內容以堅持會話?
乾杯
肖恩
<cfscript>
import facebook.sdk.FacebookApp;
import facebook.sdk.FacebookGraphAPI;
// Replace this with your appId and secret
APP_ID = "";
SECRET_KEY = "";
SCOPE = "publish_stream";
if (APP_ID is "" or SECRET_KEY is "") {
// App not configured
facebookGraphAPI = new FacebookGraphAPI();
} else {
// Create facebookApp instance
facebookApp = new FacebookApp(appId=APP_ID, secretKey=SECRET_KEY);
// See if there is a user from a cookie or session
userId = facebookApp.getUserId();
if (userId) {
try {
userAccessToken = facebookApp.getUserAccessToken();
facebookGraphAPI = new FacebookGraphAPI(accessToken=userAccessToken, appId=APP_ID);
userObject = facebookGraphAPI.getObject(id=userId);
userFriends = facebookGraphAPI.getConnections(id=userId, type='friends', limit=10);
authenticated = true;
} catch (any exception) {
// Usually an invalid session (OAuthInvalidTokenException), for example if the user logged out from facebook.com
// this is where the error occurs
userId = 0;
facebookGraphAPI = new FacebookGraphAPI();
}
} else {
facebookGraphAPI = new FacebookGraphAPI();
}
// Login or logout url will be needed depending on current user state.
if (userId) {
logoutUrl = facebookApp.getLogoutUrl();
} else {
parameters = {scope=SCOPE};
loginUrl = facebookApp.getLoginUrl(parameters);
}
}
在某個OAuth響應中是否有'expires_in'成員? –
不是我注意到的。奇怪的是,如果你再次刷新頁面,登錄看起來再次激活。有任何想法嗎? –
'code'應該在您收到後立即使用一次,以獲取訪問令牌 - 您使用訪問令牌調用API - 您是否嘗試多次使用相同的代碼? – Igy