如何通过别名(FQL)获取FB组

时间:2014-03-04 10:20:53

标签: facebook-fql alias facebook-group

是否有任何方法可以通过它的别名(用户名)来获取组?

SELECT id, name, pic_big, type, url, username FROM profile WHERE username='somealias'

适用于网页,但不适用于群组!对于组返回

(#803) Some of the aliases you requested do not exist: somealias

1 个答案:

答案 0 :(得分:3)

profile表类似于usergrouppageeventapplication表的父类。 (见https://developers.facebook.com/docs/reference/fql/profile/

它有字段username,但此字段中的值是从相关表中填充的,而表格组没有字段username(请参阅https://developers.facebook.com/docs/reference/fql/group)。因此,当我们使用where id = someid查询个人资料时,我们会得到以下结果:

SELECT id, name, pic_big, type, url, username FROM profile WHERE id= '195466193802264'
{
  "data": [
    {
      "id": 195466193802264, 
      "name": "Facebook Developers", 
      "pic_big": "https://www.facebook.com/images/litestand/bookmarks/sidebar/icons/groups/icon-default.png", 
      "type": "group", 
      "url": "https://www.facebook.com/groups/195466193802264/", 
      "username": ""
    }
  ]
}

如您所见,群组的用户名为空。

<强>更新

经过一番调查后,我发现群组可以拥有用户名。他们不能,但在@符号之前的群组电子邮件部分是用户名。

当您查询配置文件时,如果您只指定其用户名,则不会收到任何内容。但如果您要添加其名称,您的论坛就会出现。

示例:

SELECT id, name, pic_big, type, url, username FROM profile 
  WHERE username = 'rock.mfc' and type = 'group'

将导致

{
  "data": [
  ]
}

但查询

SELECT id, name, pic_big, type, url, username FROM profile
  WHERE name = 'ROCK MUSIC FANS CLUB' and username = 'rock.mfc' and type = 'group'

将提供所需的结果:

{
  "data": [
    {
      "id": 268045023346892, 
      "name": "ROCK MUSIC FANS CLUB", 
      "pic_big": "https://www.facebook.com/images/litestand/bookmarks/sidebar/icons/groups/icon-guitar.png", 
      "type": "group", 
      "url": "https://www.facebook.com/groups/rock.mfc/", 
      "username": "rock.mfc"
    }
  ]
}

希望它能帮到你。