2012-05-30 69 views
4

由於離線訪問現在由Facebook停止,我如何存儲/獲取新的訪問令牌。我嘗試了很多。代碼如下。 我不得不放棄在https://graph.facebook.com/me/friends?access_token=在Android應用程序中存儲Facebook訪問令牌

String url = "https://graph.facebook.com/oauth/access_token?client_id=appid&client_secret=secretid&grant_type=fb_exchange_token&fb_exchange_token=access_token"; 



      HttpClient httpclient = new DefaultHttpClient(); 
      HttpGet httpget = new HttpGet(url); 

      try{ 
       HttpResponse response = httpclient.execute(httpget); 

       HttpEntity entity = response.getEntity(); 
       is = entity.getContent(); 

       BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8); 
       StringBuilder sb = new StringBuilder(); 
       String line = null; 

       while ((line = reader.readLine()) != null) { 

        sb.append(line + "\n"); 

       } 

       is.close(); 
       result=sb.toString(); 
       result = result.split("=")[1]; 
       AppLog.logger(result); 

      } 
      catch(Exception e) 
      { 
       AppLog.logger("Error in JSON"); 
      } 

訪問令牌如何交換令牌?請幫忙。

+0

你在結果中得到什麼?請在這裏打印。 –

+0

我剛剛發現了誓言異常errors.nothing else.I認爲訪問令牌需要保存到其他地方過期。 Thanx幫助 –

+0

嘿,我問你你在「結果」變量?請使用「Log.d(」Result - >「,」「+ result);」並在這裏複製過去。你可以在Logcat中看到這個。 –

回答

相關問題