How would I get a list of 'friends' who have added my Facebook application? - facebook

I'm really struggling with something that should be a simple matter: Showing a user of my Facebook app a list of their friends also using the app. Is there nothing built into the APIs to allow such a common request?
The only thing I can think of to do is to get the list of the user's friends, and then get all the users from my database who are in that list, and then fetch information for each of those facebook ids. But that seems an extremely roundabout way of doing things...

The only way I've found to do this is to use FQL and a previously documented, but now undocumented field:
SELECT uid,name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=<user's uid>) AND is_app_user=1 ORDER BY name
The undocumented field is the user.is_app_user, which is listed in the old documentation wiki but not in the shiny new docs. No idea if this means it'll be removed in the future, but there doesn't seem to be any other way to get this data with the new Graph API.
Just in-case you're still using the old REST API, you can also call the friends.getAppUsers method.

You can actually use Facebook's old REST API to do this by sending a GET request to: https://api.facebook.com/method/friends.getAppUsers
If you need JSON data back, then add the parameter format=json
You need an access token to do this. See the documentation here:
http://developers.facebook.com/docs/reference/rest/friends.getAppUsers/

Related

Get list of events user is attending on Facebook

I'm trying to get list of events my friend / user attends. This info is publicly visible through Facebook pages.
I'm making a request to /userid/events but it returns empty array of results, though user does have upcoming events and calling /me/events is working. (all is ran in graph explorer)
I couldn't find any documentation about any limitations or required permissions to explain why it's not working e.g. this link
Is it a bug? How to workaround it?
You can use /userid/events with a user who auzhorized your App, but using /me/events is recommended. Either way, just because stuff is public on facebook.com does not mean you can get it with the API. You always need to authorize users before you can get any data, for privacy reasons.
In other words: It´s not a bug, there is no workaround, it´s not possible without user authorization.

Get Facebook user work

I'm trying to write some application that scan user's group posts. When I read the group feed posts using the API I’m interested to get some information on the one who posted this post ('from' field). The graph API today gives only the id and the name of this person. I'm interested also in his work place. I tried taking the user id and to access the / resource and to get his work field , but this field is not returned. When I’m looking on the same user profile in Facebook I see his work place is public, even I’m not connected with him.
Anything I can do to get this user work with the existing Facebook API?
Normally, if the work history info is not public, you'll need the "user_work_history" permission (see https://developers.facebook.com/docs/facebook-login/permissions#reference-extended-profile).
If it's public, you can try calling the
/{USER_ID}?fields=id,work

How to get a list of people who have checked into a place in Facebook

I'm trying to use Facebook API to get a list of people who checked into a place.
When typing in the search box in Facebook UI People who have been to THE_PLACE I get a long list containing many people, also people who are not my friends or friends of friends.
However, when I try to get the same information from the Facebook API, I get a list that only contains my friends who checked in. The FQL I used is the following (and also some other variants that didn't do better): SELECT author_uid FROM checkin WHERE target_id = THE_UID_OF_THE_PLACE
Am I doing something wrong or is this simply impossible to get via API the same information I can access through the UI?
For privacy reasons, this is not possible at all. Also, FQL is deprecated. I have answered a similar question here: facebook graph API - get last checked users to place/page

Facebook api: get users by work

Is it possible to get all Facebook users by work ID? I tried to find it via google but I'm getting the results I need.
I have the 'work ID' (which is infact a page, right?), but now I need all users that work there..
No, there isn't a way to get all users by work directly from FB. You can query the user table to get a particular user's work history but the converse isn't possible. Perhaps LinkedIn offers that kind of data ? But Facebook doesn't AFAIK.

Facebook Graph API: user gender

The old Facebook API provided the user sex/gender as part of the default user data. Apparently the new Graph API does not provide that information, even though the documentation says that it does.
I've heard people say that you need to request special permissions to get it and other pieces of data, but I have not been successful in getting it to work.
Does anyone have an example, using the Facebook Graph API, of how to get the user's gender and/or location (city/state/country/whatever)?
You need user_location permission to get the location according to the API reference.
GET https://graph.facebook.com/USER_ID?fields=gender,location
The Graph API tool explorer is a really handy tool for checking the output.
Just FYI, location (City and state only, country is still missing) and gender have been added to the Graph API sometimes today.
I was testing an app tonight and noticed there was a couple more fields :)
I see this has an open bounty even though the question is really really old.
You can get the gender of any user using Open Graph even without any access_token.
GET https://graph.facebook.com/userid
json_decode the data
gender will be in the `gender` element of the returned array.
EDIT : user location, hometown, country etc are no more there in the /me. seems like Fb removed those, even if they are public.
Hope this helps
As far as I can tell some permissions like user_location simply aren't working at the moment. I can get email permissions and some others but for most of the user_... ones, nope. Yes they are wrong about gender as part of default data and there appears to be no permission for it either. So use the old api until the kinks in the new one get worked out.