Facebook Access Token storing in android app

青春壹個敷衍的年華 提交于 2019-12-23 15:34:54

问题


Since the offline access is stopped by facebook now, how do I store/get a new access token. I have tried a lot. The code is below. I have to give the access token in 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");
            }

How to exchange token?? Please help.


回答1:


Why don't you use the Facebook SDK for Android?



来源:https://stackoverflow.com/questions/10816773/facebook-access-token-storing-in-android-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!