Graph API won't return friends' religions - facebook

I have a screen where users can select Facebook friends. After submitting the form, I'm requesting a profile object from Facebook with specific fields (e.g.: https://graph.facebook.com/some_id?fields=id,name,religion&access_token=xxx).
When I request my own profile data with the religion field in the request, I'm seeing the value properly included with the result. When I request my friends' profile data, the response is not including their religion even though I can see it when viewing their profile page directly.
I have made sure that I am requesting both user_religion_politics and friends_religion_politics permissions prior to making this call (and am using the updated access token). What's going on?

After creating two test user accounts, it appears that one of two things must be true in order to access a friend's religion via the Graph API:
The friend must make their religion info "Public". Setting it to "Friends of Friends" for example is not enough to let it be retrieved by the API for some reason, regardless of our friendship.
The friend must authorize the app's friends_religion_politics permission. By authorizing that permission on my own account, I am not telling Facebook that I want to allow access to my friend's religion info. Instead, I am telling Facebook that I want to allow my own religion info for other friends who are requesting it via Graph API.
The second point is a very important distinction, and I wish it were spelled out in the documentation as such. The permission is essentially worthless for my needs as is stands now, unfortunately.

Related

How to get my own Facebook user timeline using Graph API?

I would like to get all the posts and updates that are normally displayed in FB official application for MY account (this includes updates from my friends and liked pages).
I wasn't able to find any details how to get that, the only thing I've managed to get is my own posts.
Anyone got any experience with that using current Graph API verion (3.3)?
All the alternate FB clients (ex. Friendly) must be doing this somehow.
There is no way to get ANY data of users who did not authorized your App. Which means, there is no way to get posts of friends. You can only get your own friends, with the user_posts permission and the /me/posts endpoint. If some Apps access friend data without their authorization, they are most likely doing something that is not allowed.
Here is what I found in their API docs:
There are two scopes:
The user feed requires the user's permission
The public feed has fewer capabilities but doesn't require perms

How to retrieve the public information by using Facebook API?

I have a question about how to retrieve a specific person's information that is set to public by Facebook API (ex: email, location)? My idea is, (the app) to get the information that is set to public without asking the permission from the user.
I understand the Facebook Graph API could help us to retrieve the public_profile (graph.facebook.com/me), but that is very few and limited in v2.0+ (only id,name,first_name,last_name,link,gender,locale,timezone,updated_time,verified).
I also understand we can use scope in the fb:login-button (in the app) to get the user's permission to access the information. But in that case, since the user has granted it, therefore, even the information is set to private but the app can still access it, which is Not what I need.
In Graph API v1.0, we can use the API call (https://graph.facebook.com/me) to get the basic_info, which includes the information that is set to public. Since the v1.0 has already expired, therefore, I just wonder how I can get the public information by Graph API v2.0+, even other than the Graph API is fine.
Thanks.
As mentioned by #CBroe, it's not possible to retrieve such data without the user's permissions. Moreover, the info you are looking for has always been locked behind a permission even on v1.0: email and user_location
If you have a valid reason to ask for this info then explain it in your app and let the users decide.
Ref. https://developers.facebook.com/docs/facebook-login/permissions/v2.3

Facebook API for Share returning empty results set

I am new to Facebook API. I am building a Facebook app to fetch all the name of people who shared, commented and liked a post in a tabular format. I am able to get the like and comment details through Facebook API but can not find and proper API to get the share details.
I am using
https://graph.facebook.com/post_id?fields=sharedposts&access_token=my_access_token.
This API is returning an empty result set. And I have granted all the available permission to the access_tokn. Can anyone tell me ,Is there any other API that I can use. I saw a option of scraping the Facebook page for share,but I don't want to go that way because Facebook keeps on updating every thing.
I'm having the same problem as you, but I think I'm going a little step forward.
Try adding a limit to your sharedposts and maybe it will return some data:
Try this way:
https://graph.facebook.com/post_id/sharedposts?access_token=my_access_token&limit=1000
That should work for a regular post.
EDIT: Maybe the problem could be that althought you have granted all the perms to the token, the people who share that posts have to accept that permission too.
Otherway your JSON won't return any data.
The /sharedposts endpoint will -only- retrieve posts from users who have -also- granted your app. This means that even though a post might be public on a users' timeline, unless they have also granted your app permissions, you will not be able to retrieve that post.
For example: a user posted to a page and the post is public. This post can be retrieved with an access token. Let's assume that the user also shared this post to their own timeline. But, since the user has not granted permissions to your app, you will not be able to see this post using the /sharedposts edge on the original post (on the page). This also holds if the user shared their post publicly to his timeline.
This behaviour is by design; the API is more restrictive in returning user data than the website is. This holds for multiple endpoint and this is one of the examples where it is the case.
Source: https://developers.facebook.com/bugs/1404733043148335

Using single access token to get the 'likes' of other users

Using the normal Facebook website, one can get to a page showing which pages a user has 'liked'.
From the graph API, it is possible to get this for pretty much all pages, using graph.facebook.com/userid/likes?access_token=MYACCESSTOKEN.
However, I need to be able to do the same - i.e. get the list of pages a user has 'liked' for normal Facebook users (and not 'pages' who have 'liked' other pages).
Is this possible with the single access token? Judging by the fact you can get this info from the normal Facebook web page, I would expect it to be possible.
Privacy works slightly differently for applications accessing the API and for users accessing the actual site.
An application doesn't have access (by default) to your friends' likes to prevent data mining. In order to get a users friend's likes, you'll need to request the friends_likes permission.
You can read about this permission and others in the documentation.

Fetching list of friends in Graph API or FQL - Appears to be missing some friends

Any chance the 'me/friends' graph api or friends FQL table return some friends only?
I've checked the results and it's slightly less than the count I see on facebook.com
In Graph API V1.0
A call to /friends on a User object (e.g. /me/friends) or a query of the friend FQL table should return all friends of that user except
Those who have deactivated their accounts
Those who have blocked your app
Those who have disabled all Platform apps from accessing their data. - If a user enables this option (see below) you can't access any information about that user via the API, including their basic info, posts they make, etc. They won't appear in the friends list of your app's user via the API.
If you find friends are missing from the response it's almost certainly for one of those reasons, and in my experience most people asking this question are asking about the third case.
The option to remove platform option is currently under Privacy Settings -> Ads, Apps & Websites -> 'Turn off your ability to use apps, plugins, and websites on and off Facebook
If you're not getting all friends in a single call and you're sure it's not because of one of those reasons, check if you have a limit parameter in your query - and increase it if it's less than the number of friends you think should be appearing.
e.g. /me/friends?limit=5000 for the maximum number of friends allowed, 5000
Note that the friends count will include users which can't be retrieved in the list (e.g. the friend_count field of the User FQL table)
In Graph API V2.0 or higher
A call to /friends on a User object will, if the user has granted your app the user_friends permission, return the friends of that user who have also granted your app the user_friends permission -
You can read more about the change from v1.0 to v2.0 in Facebook Graph Api v2.0+ - /me/friends returns empty, or only friends who also use my app or on Facebook's changelog
You need to pass a limit parameter.
'me/friends/?limit=0' it will return all your friends.
UPDATE
the parameter limit=0 returns 0 friends,
to get all your friends, you need to set the limit=5000 (it's the max number allowed)
With the introduction of the Facebook Graph API 2.0, access a user's friends list was removed and limited to just friends who use the same application. However, Facebook added two new APIs to allow retrieval of Friend names (and indirectly a friend count). The two new APIs are taggable_friends and invitable_friends.
Url:
me/taggable_friends?limit=1&fields=id,name,