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

不打扰是莪最后的温柔 提交于 2019-12-11 07:46:53

问题


Is it possible (using the facebook graph API) to get the last 5 posts made by a Facebook Page?

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.

The following call works without an auth token for example: https://graph.facebook.com/nike

But this one doesn't: 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

To summarize:

  1. Is this really a limitation of the 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?

  3. Is it perhaps possible using a server-side SDK?

EDIT: Looks like the best way to do this is server-side with a long-lived App Access token.


回答1:


Is this really a limitation of the 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?

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. 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)-

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?

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.



来源:https://stackoverflow.com/questions/18449278/get-a-facebook-pages-public-posts-without-an-auth-token

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!