[英]How to get pageId for pages the facebook user is an admin of? Using facebook connect
The user authenticates using Facebook Connect and once that's done I want to retrieve the pageIds for the pages he is a fan of. 该用户使用Facebook Connect进行身份验证,完成后,我想检索他喜欢的页面的pageIds。 Once that's done; 完成后; I want to publish something to the wall of that facebook page. 我想在该Facebook页面的墙上发布一些内容。
I found methods describing how to publish to a page in the facebook documentation; 我在facebook文档中找到了描述如何发布到页面的方法。 but those methods require a pageId variable. 但是这些方法需要pageId变量。 I'm not sure how to get that variable since my app uses facebook connect and is not installed "in" the facebook page. 我不确定如何获取该变量,因为我的应用使用了Facebook Connect,并且未“安装”在Facebook页面中。
I know this is possible since Seesmic Desktop (formerly Twhirl) has similar functionality. 我知道这是可能的,因为Seesmic Desktop(以前称为Twhirl)具有类似的功能。
Does anyone know how to do this? 有谁知道如何做到这一点?
As of 3/10/10, there is no method to quickly discover what pages a user is an admin for. 截至3/10/10,还没有方法可以快速发现用户是管理员的页面。 However, you can use a single FQL call, see below. 但是,您可以使用单个FQL调用,请参见下文。
SELECT page_id FROM page_admin WHERE uid = *UID*
in PHP, this looks like: 在PHP中,这看起来像:
$this->fb = new Facebook('api_key', 'api_secret');
$fb_uid = $this->fb->get_loggedin_user();
$query = "SELECT page_id FROM page_admin WHERE uid = " . $fb_uid;
try{
$array = $this->fb->api_client->fql_query($query);
return $array;
} catch (Exception $e){
return false;
}
this will return a PHP array like this 这将返回这样的PHP数组
Array
(
[0] => Array
(
[page_id] => 12341234
)
[1] => Array
(
[page_id] => 43214321
)
)
I don't know if you've solved this problem but I was looking into doing something similar with php. 我不知道您是否已经解决了这个问题,但我正在考虑使用php做类似的事情。 I've been reading the facebook api wiki and trying stuff out with their test console and I found that if you use the pages.getInfo and only ask for the page_id it'll give you a list of pages that the user is a fan of. 我一直在阅读facebook api Wiki,并尝试使用其测试控制台进行试验 ,发现如果您使用pages.getInfo并仅询问page_id,它将为您提供用户喜欢的页面列表。 After that it's just a matter of checking if their the admin to that page and figure if they want to post to it. 之后,只需检查他们的管理员是否对该页面进行管理,并确定他们是否要发布到该页面。
I'd give you some code but we're not working in the same language and I haven't implemented anything yet. 我会给您一些代码,但是我们使用的不是同一语言,并且我还没有实现任何东西。 (I figure this might have been resolved by you since the question is pretty old but I figured that I'd answer seeing how you were one of the top google results, in case someone else stumbled upon it.) (由于问题已经很久了,我认为这可能已经由您解决了,但是我认为我会回答看您是Google最佳搜索结果之一的情况,以防其他人偶然发现它。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.