获取Facebook页面公共信息 [英] get facebook page public info

查看:185
本文介绍了获取Facebook页面公共信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Facebook应用程序,尝试使用php中的Facebook图形api获取页面的公共信息.

I have a facebook app that tries to get a page's public info using the facebook graph api in php.

我使用此链接https://graph.facebook.com/oauth/access_token?client_id={APP_ID}&client_secret={APP_SECRET}&grant_type=client_credentials获得了应用访问令牌,但是当我使用它来获取页面信息时,会收到"400错误请求"响应.

I got an app access token using this link https://graph.facebook.com/oauth/access_token?client_id={APP_ID}&client_secret={APP_SECRET}&grant_type=client_credentials but when I use that to get a page's info I get a "400 bad request" response.

我连接到此:https://graph.facebook.com/{PAGE_ID}?access_token={ACCESS_TOKEN_FROM_PREVIOUS_CODE}

如果我使用图形资源管理器"应用程序中的访问令牌,它可以工作,但这可能是用户访问令牌.

If I use the access token from the "Graph Explorer" app, it works but that is probably a user access token.

如果我使用facebook通过上面的oauth链接生成的令牌或由"{APP_ID} | {APP_SECRET}"组成的访问令牌,如他们在

If I use the token that facebook generates with the oauth link above or the access token composed of "{APP_ID}|{APP_SECRET}" as they suggest in the access tokens documentation page it doesn't work.

页面api参考中,他们说应用令牌应该足以获取页面的公开信息.

In the page api reference they say an app token should be enough to get a page's public info.

推荐答案

我刚刚使用App Access令牌(App-ID | App-Secret)进行了尝试,它的工作原理如下:

I just tried it with an App Access Token (App-ID|App-Secret), it works perfectly fine like this:

https://graph.facebook.com/bladauhu?access_token=App-ID|App-Secret

如果您的页面不是公开页面,则只能使用用户访问令牌(来自该页面的管理员用户)使用.可能是它不起作用的原因.从任何应用程序中获取应用程序ID和应用程序秘密,并确保该应用程序也是公开的(应用程序设置"中的状态和评论"标签-您是否希望该应用程序及其所有实时功能向公众开放?吗?".

If your page is not public, it will only work with a User Access Token (from a User who is Admin of the page). May be the reason why it does not work. Take App-ID and App-Secret from any App and make sure the App is public too ("Status & Review" tab in the App settings - "Do you want to make this app and all its live features available to the general public?").

这篇关于获取Facebook页面公共信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆