创建Facebook访问令牌而无需登录 [英] Create Facebook access token without logging in
问题描述
我想在我的应用程序中接收已定义的Facebook页面的公开帖子.我已经集成了FacebookSDK,并在Facebook开发人员控制台中创建了一个新应用.我的请求如下所示:
I want to receive the public posts of a defined facebook page in my app. I already integrated the FacebookSDK and created a new app in the Facebook developer console. My Request looks like this:
new Request(
null,
"/176063032413299/feed",
null,
HttpMethod.GET,
new Request.Callback() {
public void onCompleted(Response response) {
tv.setText(response.getRawResponse());
}
}
).executeAsync();
服务器回答,我需要访问凭证.但是我不希望我的用户在使用我的应用程序时登录.那么是否可以选择不登录就获取访问令牌?我只想读取公共数据.我对发布或阅读私人帖子不感兴趣.
The server answers, that I need an acceess token. But I don't want my users to be logged in, when they use my app. So is there an option to get an access token without being logged in? I only want to read public data. I am not interested in publishing or reading private posts.
如果我像这样使用应用程序访问令牌,仍然无法使用:
If I use the app access token like this, it still does not work:
new Request(
null,
"/176063032413299/feed?access_token=xxx",
null,
HttpMethod.GET,
new Request.Callback() {
public void onCompleted(Response response) {
tv.setText(response.getRawResponse());
}
}
).executeAsync();
我得到答复:无效的OAuth访问令牌签名"
I get the response: "Invalid OAuth access token signature"
推荐答案
即使是公开帖子,也必须授权用户才能获得访问权限.使用 read_stream
获取所有帖子,或者使用 user_status
获取仅该用户的帖子.
Even for public posts, you have to authorize the user in order to get access. Either with read_stream
to get ALL posts or with user_status
to get the posts of the user only.
read_stream很可能不会被Facebook批准,请参阅此文档: https://developers.facebook.com/docs/facebook-login/permissions/v2.2
read_stream will most likely not get approved by Facebook though, see this document: https://developers.facebook.com/docs/facebook-login/permissions/v2.2
请记住,公开"并不意味着您无需用户授权即可获取它.应用程序不能只是刮取他们想要的内容-仍然不允许刮取: https://www.facebook.com/apps/site_scraping_tos_terms.php
Keep in mind that "public" does not mean you can grab it without user authorization. Apps can´t just scrape what they want - scraping is not allowed anyway: https://www.facebook.com/apps/site_scraping_tos_terms.php
此外,当然,如果没有用户交互(登录和授权),就无法创建用户令牌(这是您所需要的).可以在以下链接中找到有关访问令牌的详细信息:
Also, of course you can´t create a User Token (which is what you need) without user interaction (login and authorization). Detailed information about Access Tokens can be found in the following links:
- https://developers.facebook.com/docs/facebook-login/access-tokens/
- http://www.devils-heaven.com/facebook-access-tokens/
顺便说一句,文档提到查看公共链接需要任何有效的访问令牌".-因此,您可能只能获得链接.
Btw, the docs mention that "Any valid access token is required to view public links." - So you may be able to get links only.
来源: https://developers.facebook.com/docs/graph-api/reference/v2.2/user/feed
要调试访问令牌,请使用Facebook调试器: https://developers.facebook.com/tools/debug/
For debugging Access Tokens, use the Facebook Debugger: https://developers.facebook.com/tools/debug/
我刚刚意识到您只是想获取Facebook页面的公共供稿,而不是用户个人资料.为此,您可以只使用一个应用程序访问令牌.它永远不会过期并且易于创建: App-ID | App-Secret
.查看文档以获取更多信息.请记住,如果页面受到年龄或国家/地区的限制,则需要使用用户令牌或页面令牌.
I just realized that you just want to grab the public feed of a Facebook Page, not a User Profile. For that, you can just use an App Access Token. It´s never expiring and easy to create: App-ID|App-Secret
. Check out the docs for more information. Keep in mind that you would need to use a User Token or Page Token if the Page is restricted by age or country.
这篇关于创建Facebook访问令牌而无需登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!