Can't access friends's informations with the graph API - facebook

I'd like to retrieve, for instance, a friend's birthday, using the graph API.
So I pick a friend whose birthday my profile can see, go to the Graph API Explorer, generate an access token with the friends_birthday privilege, and input [friend_name]/?fields=birthday and... it doesn't return anything. The birthday field on the side is grayed out, with a mouse-over text that says
"Field is empty or disallowed by the access token".
The worst part is that it works fine for some friends, but not for others. Is it related to the level of visibility they set for this information on their profile? I assumed that the app can see everything my profile can see (if I give it full privileges), but maybe that's not the case. Or is there something wrong with my request?

I had the same problem and the answer is that your friend can change the permissions it gives to apps. So, for the Graph API Explorer app your friend would need to give the user_birthday permission to the app in order for you to see their birthday through the app (and you have to give the app the friends_birthday permission as well).
See here for the comment that helped me figure that out.

Related

Facebook user profile pic no longer accessible?

(I'm aware of this question, but it's outdated to the point of no longer working, so asking again.)
With the Facebook API it used to be that all profile pictures were considered public, and you could get one for anyone without any access tokens like this:
https://graph.facebook.com/4/picture
Now in 2020 it seems that it only works for public images like Zuck there. I have a tool for Facebook page admins that shows a list of people who liked page posts, but when I try to show user pictures in the list they all now come up blank because "This object does not exist or does not support this action".
The docs now say "This document refers to a feature that was removed after Graph API v3.2". But I could not find any more information about this deprecation. Is it now just impossible to show the picture of a user without having a user access token, or has the way to call it just changed?
The feature has not been removed, but now for users that don't have their profiles set as public, you need to provide an access token.
For instance suppose you use the Page API to list all the people who commented on a post. Previously you could show the profile pics of commenters by just linking to https://graph.facebook.com/<UID>/picture. However now you need an access token for that Page, and to then access the pic as https://graph.facebook.com/<UID>/picture?access_token=<TOKEN HERE>.
I have not tested this with apps, but I would assume that also to get the profile pics of app users based on their app-scoped UID, you'd need to include an access token there as well.

How can I tell if someone is a friend of mine in Facebook Graph API V2.0 and above?

In my App, I go through different groups and pages, and check public posts that were posted by people that haven't installed my App.
How can I tell if a person that posted something is a friend of mine or not?
I am well aware that \me\friends returns only the list of friends who also installed my app, I don't want to get the full list, only check a specific person.
I am also well aware that Facebook currently returns app-scoped Facebook ID of a user of enters my application, but also returns public data about people using their non-app-scoped FB ID - however without this simple piece of info.
Thanks in advance
Unfortunately this is not possible until both persons have given your app the user_friends permission.
See
https://developers.facebook.com/docs/graph-api/reference/v2.2/user/friends#readperms
https://developers.facebook.com/docs/graph-api/reference/v2.2/user/friends#readmodifiers
You can't. The other user needs to login to your app and approve user_friends permission to your app. Otherwise it means they they have not approved it and you will not get the information

Get facebook user info

I'd like to know if it is possible to get userid or email for all people with same first name by using FQL and API. I mean all people with first name, like Mary, they don't have be my friends or fans. Thanks.
Not possible.
FB user must give you permission to query their account information. Until then, you can't get any information on them (so of course, you can't query every FB user named Mary).
No. You can't do that.
As Simon said FB user must give you permission to query their account information. An APP can access information for only those users, who have given that permission to the APP.
For example, the apps that you have mentioned in comment, social lead freak etc. will only show the results for those users which have given permission to that particular app. This means that there can be thousands of users on Facebook with the first name "Marry", but out of those thousands of users, only around 200 are using that APP (that is, have given permissions to access their data). Hope that explains the why they are doing that partially.

Getting a permission to see information for all the users in Facebook

When I use the search box in Facebook and try to find a user, it shows me a list of all the matching users while I'm typing, along with additional information on them, such as the city they live in, and when I enter their wall/timeline, I can see more information. However, when I use Facebook Graph API to search for users, I get only basic information, and must have a permission for each user in the results to get more. Why is that? Is there a way to be able to see more information for all the users without having a permission for each of them?
[…] and when I enter their wall/timeline, I can see more information.
Only if they have the visibility of their profile to public, though. Otherwise, you won’t see much on a user’s profile if you are not friends with them.
However, when I use Facebook Graph API to search for users, I get only basic information, and must have a permission for each user in the results to get more.
Why is that?
Because, naturally, you as a normal user browsing through a couple of search results on Facebook is something completely different than offering an app the capability to access all that information for every Facebook user from ID 1 to 99999999999, and then build some huge data mining thing upon it … I think that should be quite obvious.

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.