Facebook的访问令牌在Android应用程序存储 [英] Facebook Access Token storing in android app
本文介绍了Facebook的访问令牌在Android应用程序存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
由于离线访问是由Facebook的现在停了,我怎么存储/获取新的访问令牌。我已经尝试了很多。在code如下。
我不得不放弃在 https://graph.facebook.com/me/friends访问令牌?的access_token =
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.
推荐答案
你为什么不使用的的Facebook SDK为Android ?
这篇关于Facebook的访问令牌在Android应用程序存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文