检索 Facebook 页面所有者/管理员的个人资料 ID

发布于 2024-12-11 02:55:26 字数 782 浏览 0 评论 0原文

在 PHP SDK 的早期版本中,应用程序能够获取拥有安装应用程序的页面的用户的配置文件 ID。

$facebook->get_profile_user()

这在没有最终用户授权访问 Facebook 应用程序的情况下是可能的。

但是我在新的 JS 或 Graph API 中找不到任何类似的东西。我能找到的最接近的东西是 https://graph.facebook.com//admins ,但是这个调用似乎不起作用,或者需要额外的权限:

Access Token:AAADF5PRI7BkBAKSz9Wqfbkuib6JH7WkZCQDZBgLNO10s1ZAMKF7BO7Y3YCVqkYNuCJ9QroWHYYn8n5wC8diPuBDPGsNUS5tDnZAZA6rFSx28VtpvVhUlY
Graph API: /210093142392039/admins
$this->facebook->api('/291231207559006/admins')

( ! ) Fatal error: Uncaught OAuthException: (#210) Subject must be a page. thrown in /html/classes/facebook/base_facebook.php on line 1033

是这样的功能没了?我们使用配置文件 ID 作为数据源中的密钥,因此最好保留相同的密钥,如果没有,我们可以开始存储页面 ID,但这将导致用户必须重新初始化应用程序。

In a previous version of the PHP SDK there was the ability in an App to get the Profile ID of the user that owned the page where the app was installed.

$facebook->get_profile_user()

This was possible without having the end user authorize access to the Facebook App.

However I can't find anything similar in the new JS or Graph API's. The closest thing I could find was the https://graph.facebook.com/<page_id>/admins, however it seems this call either doesn't work, or requires addition permissions:

Access Token:AAADF5PRI7BkBAKSz9Wqfbkuib6JH7WkZCQDZBgLNO10s1ZAMKF7BO7Y3YCVqkYNuCJ9QroWHYYn8n5wC8diPuBDPGsNUS5tDnZAZA6rFSx28VtpvVhUlY
Graph API: /210093142392039/admins
$this->facebook->api('/291231207559006/admins')

( ! ) Fatal error: Uncaught OAuthException: (#210) Subject must be a page. thrown in /html/classes/facebook/base_facebook.php on line 1033

Is this functionality gone? We were using the Profile ID as a key in a datasource, so it'd be ideal to keep this same key, if not we can start storing the page-id instead, however this would the users would have to reinitialize the app..

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

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

发布评论

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

评论(2

萌酱 2024-12-18 02:55:26

2011 年 9 月 22 日之后,需要管理页面权限才能执行此操作。
您必须请求manage_pages权限,获取页面access_token,然后使用页面access_token发出管理员请求。

请参阅 http://developers.facebook.com/docs/reference/api/permissions / 获取更新的权限。

After September 22, 2011, manage_pages permission is required to do that.
You must request for the manage_pages permission, get the page access_token and then make the admins request with the page access_token.

Please refer to http://developers.facebook.com/docs/reference/api/permissions/ for updated permissions.

捶死心动 2024-12-18 02:55:26

好吧,实际上我不久前也遇到过同样的问题并找到了解决方案。我所做的是传递用户访问令牌而不是页面访问令牌。我建议你应该尝试类似的事情

$pageIds=$facebook->api('/me/accounts');
$pageAccessToken=$pageIds["data"][1]["access_token"]; //get the access token for page "[1]" over here  

然后尝试

facebook->api('/<page id>/admins', 'get' , array("access_token" => $pageAccessToken));

Well, I actually had the same problem some time back and found a solution for it. What i was doing was passing the user access token intead of the page access token. I would suggest that you should try something like

$pageIds=$facebook->api('/me/accounts');
$pageAccessToken=$pageIds["data"][1]["access_token"]; //get the access token for page "[1]" over here  

and then try

facebook->api('/<page id>/admins', 'get' , array("access_token" => $pageAccessToken));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文