如何为Android制作更长的Facebook Graph API会话

时间:2012-07-12 09:57:25

标签: android facebook facebook-graph-api

我看到了这个问题:The session has been invalidated because the user has changed the password当我在寻找同一个问题的答案时,但我不知道如何让会话更长时间的安卓,所以有人可以告诉我如何。我认为必须改变这两行:

String access_token = mPrefs.getString("access_token", null);
long expires = mPrefs.getLong("access_expires", 0);

但我不知道如何更改

1 个答案:

答案 0 :(得分:0)

正如reference中提到的那样:

  

步骤8:扩展访问令牌

     

随着offline_access的弃用,你需要扩展你的   每次用户打开您的应用时都会访问access_token。为此,请致电   facebook方法extendAccessTokenIfNeeded在你的应用程序中   onResume()函数:

     

public void onResume(){
      super.onResume();       facebook.extendAccessTokenIfNeeded(this,null);   }

     

注意:请确保您拥有最新的Android SDK   https://github.com/facebook/facebook-android-sdk/