简体   繁体   English

获取没有身份验证令牌的Facebook Page的公开帖子

[英]Get a Facebook Page's public posts without an auth token

Is it possible (using the facebook graph API) to get the last 5 posts made by a Facebook Page ? 是否可以(使用facebook graph API)获取Facebook Page的最后5条帖子?

I would like to display this information in an Android app and want to avoid the overhead of using the Facebook Android SDK to avoid showing the " [App] would like to access your public profile and friend list " message because it's annoying and inaccurate. 我想在Android应用程序中显示此信息,并希望避免使用Facebook Android SDK的开销,以避免显示“ [App]想访问您的公开资料和朋友列表 ”消息,因为这很烦人且不准确。

The following call works without an auth token for example: https://graph.facebook.com/nike 例如,以下调用无需身份验证令牌即可工作: https : //graph.facebook.com/nike

But this one doesn't: https://graph.facebook.com/nike/posts 但这不是: https : //graph.facebook.com/nike/posts

{
   "error": {
      "message": "An access token is required to request this resource.",
      "type": "OAuthException",
      "code": 104
   }
}

I could scrape the HTML off of this page without an auth token but this seems like overkill for such a simple task: https://www.facebook.com/nike/posts 我可以在没有auth令牌的情况下从该页面抓取HTML,但是对于这样一个简单的任务,这似乎有些过头了: https : //www.facebook.com/nike/posts

To summarize: 总结一下:

  1. Is this really a limitation of the API? 这真的是API的限制吗?

  2. Is there a way to suppress the " [App] would like to access your public profile and friend list " message when acquiring an auth-token with no extra permissions using the Android SDK? 当使用Android SDK获取没有额外权限的身份验证令牌时,是否有一种方法可以抑制“ [应用]希望访问您的公共资料和朋友列表 ”消息?

  3. Is it perhaps possible using a server-side SDK? 使用服务器端SDK是否可能?

EDIT : Looks like the best way to do this is server-side with a long-lived App Access token . 编辑 :看起来最好的方法是在服务器端使用长期存在的App Access令牌

Is this really a limitation of the API? 这真的是API的限制吗?

No. 没有。

Is there a way to suppress the "[App] would like to access your public profile and friend list" message when acquiring an auth-token with no extra permissions using the Android SDK? 当使用Android SDK获取没有额外权限的身份验证令牌时,是否有办法禁止显示“ [[App]想要访问您的公开资料和朋友列表””消息?

Yes. 是。 If you read the documentation properly ( Post ), its clearly mentioned that any valid access token is required to fetch the details* of the posts of a page. 如果您正确阅读了文档( Post ),则它明确提到要获取页面帖子的详细信息*,需要任何有效的访问令牌。 So, you could use the App access token , which you could get without any authorization step- from here or a simple GET request (server-side)- 因此,您可以使用App access token ,无需任何授权步骤即可获取-从此处或简单的GET请求(服务器端)-

GET /oauth/access_token?
client_id={app-id}
&client_secret={app-secret}
&grant_type=client_credentials

Is it perhaps possible using a server-side SDK? 使用服务器端SDK是否可能?

Depends on you, how you want to implement. 取决于您,您要如何实现。

*Note: Of course, the posts that you can see would be the public posts only (that could be seen even if a user is logged-out); *注意:当然,您可以看到的帖子仅是公开帖子(即使用户注销也可以看到); else you might require user authentication with read_stream permission. 否则,您可能需要具有read_stream权限的用户身份验证。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM