使用 Facebook Graph API 获取公共页面状态,无需访问令牌
我正在尝试使用 Facebook Graph API 从公共页面获取最新状态,比方说 http://www .facebook.com/microsoft
根据 http://developers.facebook.com/tools/explorer/?method=GET&path=microsoft%2Fstatuses - 我需要访问令牌。由于微软页面是“公开的”,这肯定是这样吗?如果没有访问令牌,我是否无法访问这些公共状态?
如果是这种情况,为我的网站创建访问令牌的正确方法是什么?我有一个应用程序 ID,但是 http://developers.facebook.com/docs/ 上的所有示例身份验证/ 描述处理用户登录。我只想获取 Microsoft 页面上的最新状态更新并将其显示在我的网站上。
I'm trying to use the Facebook Graph API to get the latest status from a public page, let's say http://www.facebook.com/microsoft
According to http://developers.facebook.com/tools/explorer/?method=GET&path=microsoft%2Fstatuses - I need an access token. As the Microsoft page is 'public', is this definitely the case? Is there no way for me to access these public status' without an access token?
If this is the case, how is the correct method of creating an access token for my website? I have an App ID, however all of the examples at http://developers.facebook.com/docs/authentication/ describe handling user login. I simply want to get the latest status update on the Microsoft page and display it on my site.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这是设计使然。一旦可以从公共页面获取最新状态而无需访问令牌。为了阻止未经识别的匿名访问 API,这一点已被更改。您可以使用图形 API 通过以下调用获取应用程序的访问令牌(如果您没有为您的网站设置 Facebook 应用程序 - 您应该创建它):
这称为应用程序访问令牌。然后,您可以使用上面的应用程序访问令牌继续进行实际的 API 调用。
希望这有帮助
This is by design. Once it was possible to fetch the latest status from a public page without access token. That was changed in order to block unidentified anonymous access to the API. You can get an access token for the application (if you don't have a Facebook application set for your website - you should create it) with the following call using graph API:
This is called App Access Token. Then you proceed with the actual API call using the app access token from above.
hope this helps
您可以使用 AppID 和密钥来获取任何页面的公开帖子/提要。这样您就不需要获取访问令牌。像下面这样称呼它。
并获得职位。
You can use AppID and Secret key to get the public posts/feed of any page. This way you don't need to get the access-token. Call it like below.
And to get posts.
如果没有访问令牌来读取公共页面状态,则无法再使用 Facebook Graph API,这在 Facebook API 权限中称为页面公共内容访问。访问令牌甚至还不够。您必须将 appsecret_proof 与访问令牌一起使用才能验证您是否是合法用户。 https://developers.facebook .com/blog/post/v2/2018/12/10/verification-for-individual-developers/。
如果您是个人开发人员,您可以访问三页数据(有限),除非您拥有商业应用程序。
It's no more possible to use Facebook Graph API without access token for reading public page statuses, what is called Page Public Content Access in Facebook API permissions. Access token even is not enough. You have to use appsecret_proof along with the access token in order to validate that you are the legitimate user. https://developers.facebook.com/blog/post/v2/2018/12/10/verification-for-individual-developers/.
If you are individual developer, you have access to three pages of the data (limited), unless you own a business app.
您只需请求浏览器请求的站点,然后从 HTML 中提取帖子即可获取帖子。
在 NodeJS 中,您可以这样做:
有关如何检索 20 多个帖子的更多信息和示例,请参阅:https://stackoverflow .com/a/54267937/2879085
You can get the posts by simply requesting the site that your browser would request and then extracting the posts from the HTML.
In NodeJS you can do it like this:
For more information and an example of how to retrieve more than 20 posts see: https://stackoverflow.com/a/54267937/2879085
几周来我有一个类似的用例,我使用了这个 API:
https: //rapidapi.com/axesso/api/axesso-facebook-data-service/
我可以在几分钟内获取所有帖子和评论,对我来说效果很好。
I had a similar use case for some weeks and I used this API:
https://rapidapi.com/axesso/api/axesso-facebook-data-service/
I could fetch all posts and comments in some minutes, worked quite well for me.