Facebook 图形 API +脸书页面

发布于 2024-09-05 05:03:44 字数 84 浏览 3 评论 0原文

使用 Facebook 的 Graph API,给定用户名 xyz(假设他们已经验证了我的网站),我如何获取用户管理的所有 Facebook 页面的列表?

Using Facebook's Graph API, given a username xyz (assuming they've authenticated my site), how do I get a list of all of the facebook pages that the user administers?

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

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

发布评论

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

评论(9

时光礼记 2024-09-12 05:03:44

user 对象上的 accounts 属性表示:

当前用户拥有的 Facebook 页面。如果已授予manage_pages权限,则此连接还会生成可用于代表页面查询Graph API的access_tokens。

http://developers.facebook.com/docs/reference/api/user

The accounts property on the user object says:

The Facebook pages owned by the current user. If the manage_pages permission has been granted, this connection also yields access_tokens that can be used to query the Graph API on behalf of the page.

http://developers.facebook.com/docs/reference/api/user

隔纱相望 2024-09-12 05:03:44

获取访问令牌后,您可以获得用户管理的所有 Facebook 页面列表的所有详细信息。

https://graph.facebook.com/[FACEBOOKUSERID]?metadata=1&access_token=

输出看起来像

{
   "name": "Facebook Developer Garage Austin - SXSW Edition",
   "metadata": {
      "connections": {
         "feed": "http://graph.facebook.com/331218348435/feed",
         "picture": "https://graph.facebook.com/331218348435/picture",
         "invited": "https://graph.facebook.com/331218348435/invited",
         "attending": "https://graph.facebook.com/331218348435/attending",
         "maybe": "https://graph.facebook.com/331218348435/maybe",
         "noreply": "https://graph.facebook.com/331218348435/noreply",
         "declined": "https://graph.facebook.com/331218348435/declined"
      }
   }
}

After getting access token you can get all details of list of all of the facebook pages that the user administers.

https://graph.facebook.com/[FACEBOOKUSERID]?metadata=1&access_token=

The output will look like

{
   "name": "Facebook Developer Garage Austin - SXSW Edition",
   "metadata": {
      "connections": {
         "feed": "http://graph.facebook.com/331218348435/feed",
         "picture": "https://graph.facebook.com/331218348435/picture",
         "invited": "https://graph.facebook.com/331218348435/invited",
         "attending": "https://graph.facebook.com/331218348435/attending",
         "maybe": "https://graph.facebook.com/331218348435/maybe",
         "noreply": "https://graph.facebook.com/331218348435/noreply",
         "declined": "https://graph.facebook.com/331218348435/declined"
      }
   }
}
剪不断理还乱 2024-09-12 05:03:44

使用 fql 查询!这是获取用户管理员页面的最佳方式。您还可以限制名称。即具有空名称的页面 示例 fql 查询,它还为您提供页面详细信息。

SELECT page_id,page_url,name,pic_square FROM page WHERE page_id IN (SELECT page_id FROM page_admin WHERE uid = " + **UserId** + ") and name!='' 

UserId -- 管理员 ID

注意
此方法在 graph api 2.1 版本中不起作用,因为 fql 从该版本开始已被弃用

Use an fql query! That is the best way to get the pages for which the user is admin. You will also be able to restrict the names also. i.e pages with empty names A sample fql query which gives you the page details as well.

SELECT page_id,page_url,name,pic_square FROM page WHERE page_id IN (SELECT page_id FROM page_admin WHERE uid = " + **UserId** + ") and name!='' 

UserId -- Id of the admin

NOTE
This method will not work from version 2.1 of graph api as fql was deprecated from that version onwards

赠意 2024-09-12 05:03:44

这是我用的。它工作完美

$pages = $facebook->api(array('method' => 'fql.query','query' => 'SELECT page_id FROM page_admin WHERE uid = '.$uid.''));

foreach($pages as $k=>$v) {
    echo 'page id#:'.$v['page_id'].'<br/>';
}

当然这是在您为 fb 用户创建会话之后! $uid 是您为其返回托管页面列表的特定 Facebook 用户的个人资料 id#。

Here's what I use. It works perfect

$pages = $facebook->api(array('method' => 'fql.query','query' => 'SELECT page_id FROM page_admin WHERE uid = '.$uid.''));

foreach($pages as $k=>$v) {
    echo 'page id#:'.$v['page_id'].'<br/>';
}

This is of course after you have the session created for the fb user! The $uid would be the profile id# of the specific facebook user your returning of a list of managed pages for.

飞烟轻若梦 2024-09-12 05:03:44

@rmorrison - 但这不是图形 API。有了新的“喜欢”功能,您可以使用以下 URL:h ttps://graph.facebook.com/me/likes?access_token=blah!或 h ttps://graph.facebook.com/USER_ID/likes?access_token=blah!

@rmorrison - This is not graph API though. With the new "like" addition, you can use this URL: h ttps://graph.facebook.com/me/likes?access_token=blah! or h ttps://graph.facebook.com/USER_ID/likes?access_token=blah!

冷月断魂刀 2024-09-12 05:03:44

Fql 是获取其管理员用户页面的最佳方式。当其他人喜欢的用户喜欢时,将给出该用户喜欢的所有页面。

Fql is the best way to get the pages of the user for which he is the admin. As the others like likes of user will give all the pages that the user like.

甜警司 2024-09-12 05:03:44

您可以通过简单的 Facebook Graph API Hit 获取页面列表。

https://graph.facebook.com/{user-id}/accounts?access_token={access-token}

它将给出他/她创建的用户的页面列表。

You can get list of pages from a simple Facebook Graph API Hit.

https://graph.facebook.com/{user-id}/accounts?access_token={access-token}

It will give a list of pages for user which he/she has created.

影子的影子 2024-09-12 05:03:44

access_token 的有效期为一小时或更短。事后人们应该做什么才能获得详细信息。 获取结果

我试图从https://graph.facebook.com/v2.3/search?q=coffee&type=place¢er=37.76,-122.427&distance=1000&access_token=xyz< /a>

这工作了一个小时左右,但我如何在一小时后得到结果......而不需要登录。

access_token is valid for an hour or less. What should someone do in order to get the details even after. I was trying to result get the result from

https://graph.facebook.com/v2.3/search?q=coffee&type=place¢er=37.76,-122.427&distance=1000&access_token=xyz

This worked for an hour or so but how do i get the result after an hour...without going for a login.

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