嵌入公开Facebook页面的活动Feed,而不强制用户登录/允许 [英] Embed activity feed of a public Facebook page without forcing user to login/allow
问题描述
这与以前提问的问题类似,不过不管我读什么,我还是很困惑。
我有一个公开的Facebook页面,如白领域例如,其活动Feed需要嵌入到我的Android应用程序中。我了解如何获取应用程序和应用程序秘密,但我不明白如何获取短命令访问令牌,我明白是获取长期访问令牌所必需的。
根据我的理解,这可能是错误的,用户必须通过应用登录才能获得一个短暂的访问令牌,但我不想任何用户必须登录才能查看活动信息。
一旦这样,我该如何使用它将此活动Feed引入我的应用程序?
这个Facebook的文档很糟糕,所以我需要一些帮助。
如果它或任何其他需要站点特定的权限,我可以访问有关的网站。
谢谢!
要获取公开Facebook页面(如白领)的活动信息,请按照下列步骤操作:
1)通过选择现有应用程序或在此网址创建新应用程序,获取您的App-id和App-secret:
https://developers.facebook.com/apps/
2)通过向该URL发出GET请求获取访问令牌:
https://graph.facebook.com/ oauth / access_token?client_id =+ APP_ID +& client_secret =+ APP_SECRET +& grant_type = client_credentials
3)获取您的粉丝页面的页面ID。为此,您需要页面名称。转到你的粉丝页面,看看网址。它将具有以下形式:
https://www.facebook.com/ {fan-page-name}
一旦这样做,请向此网址发出GET请求:
https://graph.facebook.com/ {fan-page-name}?access_token = {access-token}
/ pre>
它将返回一堆JSON。您正在寻找第一个id元素。这是您的页面ID。
4)获取粉丝专页JSON数据,并向该网址发送GET请求:
https://graph.facebook.com/+ page-id +/ feed?access_token =+ URLEncoder.encodeUTF8(access-token)
为避免出现异常,我不得不使用
URLEncoder.encodeUTF8()。
您正在查找的数据位于data元素下。
我无法找到任何可以进行JSON解析的内容的Facebook Feed,但我确实发现这个教程将会为您做很多格式,使其看起来像Facebook。
希望帮助任何人尝试这样做。
This is similar to questions asked several times before, but no matter what I read, I'm still confused.
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?
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.
Thanks!
解决方案To get the activity feed of a public Facebook page, like White Collar, follow these steps:
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 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) 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}
Once you have that, make a GET request to this url:
https://graph.facebook.com/{fan-page-name}?access_token={access-token}
It will return a bunch of JSON. You're looking for the first "id" element. This is your page-id.
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)
To avoid having exceptions thrown, I had to use
URLEncoder.encodeUTF8().
The data you're looking for is under the "data" element.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.
这篇关于嵌入公开Facebook页面的活动Feed,而不强制用户登录/允许的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!