使用 Facebook Graph API + PHP SDK获取用户的关于数据

发布于 2024-12-29 15:38:56 字数 664 浏览 0 评论 0原文

使用Facebook Graph API和PHP SDK,我知道我可以获取用户的兴趣

$facebook->api("/me/interests")

但是,假设我有权限,我如何获取用户的关于数据?

$facebook->api("/me/about")
//gives error:
Fatal error: Uncaught OAuthException: Unknown path components: /about thrown in 
[...]/base_facebook.php on line 1028

如何获取登录用户的 Facebook About 数据?谢谢。

编辑:这是应用程序权限的图片,以及用于请求权限的代码。

我的应用程序的权限

$login_url = $facebook->getLoginUrl(array( 'scope' => 'email, publish_stream, 
user_about_me, user_interests, user_education_history'));

Using the Facebook Graph API and the PHP SDK, I know that I can get the user interests with

$facebook->api("/me/interests")

However, assuming that I have the permission to, how can I get the user's About data?

$facebook->api("/me/about")
//gives error:
Fatal error: Uncaught OAuthException: Unknown path components: /about thrown in 
[...]/base_facebook.php on line 1028

How can I get the logged in user's Facebook About data? Thanks.

EDIT: Here's a picture of the app permissions, as well as the code used to request the permissions.

The Permissions for My App

$login_url = $facebook->getLoginUrl(array( 'scope' => 'email, publish_stream, 
user_about_me, user_interests, user_education_history'));

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

白云不回头 2025-01-05 15:38:56

取决于您想要什么“关于”信息?您可以指定各个字段,但没有总体的 about 命令来获取所有有关信息。 //

$info = $facebook->api('/me?fields=id,email,work');

你可以从 http://developers.facebook.com/docs/reference/api/user/" rel="nofollow">http: /developers.facebook.com/docs/reference/api/user/

编辑,如果您想要简介,只需在字段中添加“,bio”即可

Depends what 'about' information you want? You can specify individual fields but there is no overall about command to get all about information. Just go

$info = $facebook->api('/me?fields=id,email,work');

You can get a full list of what you can request plus further commands from http://developers.facebook.com/docs/reference/api/user/

Edit, if you are wanting the bio just add ',bio' to the fields

浮生未歇 2025-01-05 15:38:56

当您未正确登录您的开发者帐户时,通常会发生此类错误未知路径组件:/xxx

这听起来似乎很明显,但我也遇到过类似的问题,直到习惯在工作前检查/更改帐户。 {>_<}

That kind of errors Unknown path components: /xxx usually occur when you are not properly logged in your developer account.

It may sound obvious, But I had similar problems until habituate to check/change accounts before work. {>_<}

鱼窥荷 2025-01-05 15:38:56

我认为这应该是:

$facebook->api("/me/bio") ;

编辑:

只需使用这个:

$facebook->api("/me") ;

您可以从中获取所有用户信息。只需解析数组以获取所需的内容即可。它输出所有与用户相关的信息

出于防止垃圾邮件的原因,某些属性(例如用户电话、地址)特意且故意不通过 API 提供。 Facebook 不允许他们通过 api

尝试一下:)

I think this should be :

$facebook->api("/me/bio") ;

EDIT:

Just Use this:

$facebook->api("/me") ;

You can get all user information from this . Just parse the array for what you required . It outputs all the user related information

Some attributes like users phone,address are specifically and intentionally not available via the API, for spam prevention reasons . Facebook does not allow them to take through api

Try with this :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文