How to retrieve the public information by using Facebook API? - facebook

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

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

Get data from other user_id with facebook graph API v3.2

I would like to know if it is possible to get basic data (name, posts...) of user in Facebook that has public profile (obviously).
I tried with GRAPH API this call:
https://graph.facebook.com/v3.2/USER_ID?fields=id,name&access_token=access_token
When I use my profile USER_ID, it returns my id and my name, but when I put another user ID, it returns this error:
Unsupported get request. Object with ID 'USER_ID' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https:\/\/developers.facebook.com\/docs\/graph-api
But I reed in documentation that the variable user_id can use in this API call, so I think that this is posible (maybe no).
I reed in other posts, that in the past you can access by username, but now no. Maybe, you only can access to your profile data?
Thanks and sorry about my english.
No, you can not access just anyone’s profile data via API, even if it is shown publicly on the website or the official apps.
The user would need to explicitly login to your app and grant it permission to access their data. Those permissions can not be granted on behalf of someone else - every single user you would want any info about, would have to do this personally.

Add extended permissions - Facebook

I created a Java program that retrieves users personal information and posts. I can retireve everything related to me but not to my friends.
I know that i have to add some extended permissions to collect information about my friends (e.g. friends_groups, friends_interests, friends_subscriptions and more) but i don't know how to add them.
I didn't use Facebook Api in my Java application. I just give a specific URL, for example :
https://graph.facebook.com/friendID?access_token=MY_ACCESS_TOKEN_HERE
and i get a JSon Object from this URL which contains the information of that user (id, first_name,last_name,link,name,updated_time) which are not useful for what i want to do.
I also tried :
https://graph.facebook.com/friendID?access_token=MY_ACCESS_TOKEN_HERE&scope=friends_activities,friends_birthday,friends_status,friends_subscriptions,friends_work_history
but again it didn't work either to my Java App or Graph Api Explorer.
Can someone explain to me how to add the extended persmissions that i need provided that i created my app in the way i explained above? Can i add the permissions inside the URL that fetches the JSon Object?
To get a person's data, your app needs to use that person's access token. To get that person's access token, that person must authorize your app (through Facebook Login). You can read more about Facebook Login in the documentation.

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

Graph API won't return friends' religions

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.