有什么办法,我可以得到一些用户或应用程序的公共提要没有登录,使用的是Android? [英] Is there any way I can get public feed of some user or application without logging in, using Android?
问题描述
在我的Android应用我想有一些Facebook的个人主页公开的饲料内容。
In my Android App I want to have contents of a public feed of some Facebook profile.
我不喜欢逼我登录了点。
I don't like to force my to log in for that.
在从FB最近的API的变化是否有可能?
Is it possible after recent API changes from FB?
修改
我应该居然问了另一个问题:我得到pulic Facebook的饲料在Android上,而不要求用户登录
I should have actually asked another question: can I get pulic Facebook feed on Android without asking user to log in?
我的答案,看到有一些线下的access_tokens(永久) - 可能我只是把它嵌入在我的应用程序?如何去做?
I see in answers that there are some offline (permanent?) access_tokens - could I just embed it within my app? How to go about it?
推荐答案
有2种方式这样做的:
1)使用的应用程序ID和秘密获取访问令牌(没有用户交互),然后用它来访问提要:
1) Using App id and secret get access token (no user interaction), and then use it to access feed:
try {
String APP_ID = "123123123123123123";
String APP_SECRET = "0123456789abcdef";
String OWNER_OF_FEED = "barackobama";
HttpClient client = new DefaultHttpClient();
HttpGet get = new HttpGet(
"https://graph.facebook.com/oauth/access_token?client_id="+
APP_ID +
"&client_secret="+APP_SECRET+"&grant_type=client_credentials");
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String access_token = client.execute(get, responseHandler);
// access_token contains sthing like "access_token=XXXXXXXXXX|YYYYYY" ,
//need to replace pipe (this is ugly!)
String uri = "https://graph.facebook.com/" + OWNER_OF_FEED + "/feed?"
+ access_token.replace("|", "%7C");
get = new HttpGet(uri);
String responseBody = client.execute(get, responseHandler);
// responseBody contains JSON-encoded feed
textview.setText(responseBody);
} catch (Exception ex) {
ex.printStackTrace();
}
2)使用RSS提要:
2) Using RSS feed:
http://www.facebook.com/feeds/page.php?format=rss20&id=6815841748
...如果你想知道:6815841748是一个Facebook的ID president奥巴马,谷歌将告诉您如何得到它。
这篇关于有什么办法,我可以得到一些用户或应用程序的公共提要没有登录,使用的是Android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!