Facebook访问令牌存储在Android应用程序中

由于Facebook现在停止了离线访问,如何存储/获取新的访问令牌.我已经尝试了很多.代码如下.

我必须在
https://graph.facebook.com/me/friends?access_token=中提供访问令牌

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");
            }

如何交换令牌?请帮忙.

最佳答案 你为什么不用
Facebook SDK for Android

点赞