0
votes

I want to get all users with their name and facebook username in a group. The following query should do it but it doesn't return usernames.

SELECT name, username  from profile where id in (SELECT uid FROM group_member WHERE gid = 'GROUP_ID')

Even though almost all users have an username, username field is null for each user in the result.

I don't think Facebook hides this information because of privacy issues because I'm able to get username with graph api using http://graph.facebook.com/uid.

2
Username doesn't exists in api v2.0WizKid

2 Answers

0
votes

That will only work with Graph API v1.0, which will be deprecated on April 30th 2015. With v2.0, it is no longer possible to get the username field.

See https://developers.facebook.com/docs/apps/changelog#v2_0_graph_api

/me/username is no longer available.

0
votes

Username and name still can retrieve by using fql. But I don't think that you can simply get the name from the group by using general query like 'uid from groupmember', this is because Facebook secure the name of Facebook user. But you can get their name/username if that Facebook user has commented on your post. This is the fql query to get the name/username of facebook user:

{
 comments = "SELECT actor_id, target_id FROM stream WHERE post_id=\"" + postid + "\"", 
 commenters = "SELECT username, name FROM profile WHERE id IN (SELECT actor_id, target_id FROM #comments)",
}

If you the administrator of the group, of course you can simply get the post_id by using fql then use the post id to get the name/username. Hope this can help to solve your problem.