这是类似于提出的问题前几次,但不管是什么我读,我仍然感到困惑。
This is similar to questions asked several times before, but no matter what I read, I'm still confused.
我有一个公共的Facebook页面,就像白领为例,其活性饲料,我需要嵌入到我的Android应用程序。我知道如何让应用程序-ID和app-秘密,但我不明白如何让短暂的访问令牌,我的理解是必要的,以获得长寿命的访问令牌。
I have a public Facebook page, like White Collar for example, whose activity feed I need to embed into my Android app. I understand how to get the app-id and app-secret, but I don't understand how to get the short-lived access token, which I understand is necessary to get a long-lived access token.
据我了解,它可以很可能是错误的,用户通过应用程序登录到得到一个短暂的访问令牌,但我不希望任何用户必须登录才能查看活动饲料。
From what I understand, which can quite possibly be wrong, the user has to login through the app to get a short-lived access token, but I don't want any user to have to login to view the activity feed.
在我有,我怎么然后用它把这项活动纳入我的应用程序?
Once I have that, how do I then use it to bring this activity feed into my app?
在Facebook的文档,这是可怕的,所以我需要一些帮助。
The Facebook documentation for this is terrible so I need some help.
如果它或其他任何需要的网站特定的权限,我有机会到有问题的网站。
If it or anything else requires site-specific permissions, I have access to the site in question.
谢谢!
推荐答案
要获得公众的Facebook页面的活性饲料,像白领,请按照下列步骤操作:
To get the activity feed of a public Facebook page, like White Collar, follow these steps:
1)获取你的App-ID和App-秘密通过选择一个现有的应用程序或创建一个新的这个网址:
1) Get your App-id and App-secret by choosing an existing app or creating a new one at this url:
https://developers.facebook.com/apps/
2),通过一个GET请求来此URL获得访问令牌:
2) Get an access token by making a GET request to this url:
https://graph.facebook.com/oauth/access_token?client_id=" + APP_ID + "&client_secret=" + APP_SECRET + "&grant_type=client_credentials
3)让你的粉丝页面的页面ID。要做到这一点,你需要的页面名称。去你的粉丝页面在Facebook和看网址。这将有这种形式:
3) Get the page-id of your fan page. To do this, you need the page-name. Go to your fan page on facebook and look at the url. It will have this form:
https://www.facebook.com/{fan-page-name}
一旦你的,做一个GET请求到这个网址:
Once you have that, make a GET request to this url:
https://graph.facebook.com/{fan-page-name}?access_token={access-token}
它会返回一堆JSON的。你要找的第一个身份证的元素。这是你的页面的ID。
It will return a bunch of JSON. You're looking for the first "id" element. This is your page-id.
4)获得转页扇JSON数据用GET请求这个网址:
4) Get the fan page JSON data with a GET request to this url:
https://graph.facebook.com/" + page-id + "/feed?access_token=" + URLEncoder.encodeUTF8(access-token)
要避免抛出的异常,我不得不使用 URLEn coder.en codeUTF8()。
您正在寻找的数据是根据数据元素。
To avoid having exceptions thrown, I had to use URLEncoder.encodeUTF8().
The data you're looking for is under the "data" element.
我是不是能找到什么,会做Facebook的的JSON解析喂我,但我没有找到这样的教程,会做很多的格式,为您使它看起来像Facebook。
I wasn't able to find anything that would do the JSON parsing of the Facebook feed for me, but I did find this tutorial that will do a lot of the formatting for you to make it look like Facebook.
希望帮助其他人试图做到这一点。
Hope that helps anyone else trying to do this.
相关推荐
最新文章