Facebook Graph API location data missing, but visible on FB site search? - facebook

I'm noticing an inconsistency with the FB Graph API.
Suppose I'm logged in (and have access_token for) user Bob. Bob isn't friends with user Jim.
If I, as Bob, via the Graph API, ask for data about Jim:
https://graph.facebook.com/jim?access_token=blah&fields=location,hometown,name,id,address
I get a structure like this back:
{
"id": "1",
"name": "Jim"
}
Note that the fields that I've requested are conspicuously missing.
However, if I log in to the FB website as Bob, and then search for Jim, I can see his location and hometown on his "About" page, even if I'm not friends with him.
Why is this? Is there some additional token permission I have to specify or field I need to ask for in order to get this data (which is evidently rather public) from the API?

Got stuck on the same issue.
As I understand from end of this page access token has to include user_location and user_hometown permissions. Tried it in api explorer but had no success - still was not able to see location information through api for users that had this info visible on their profile page.
update: answers here and here suggest that data access through api / app is more restricted than through webpage to prevent web mining. I assume it is the case regardless you use user or app permissions.

If you are using a user access token then you might need to switch to using an app access token retrieved by a call like:
https://graph.facebook.com/oauth/access_token?
client_id=YOUR_APP_ID&client_secret=YOUR_APP_SECRET&
grant_type=client_credentials

Related

Is it posible to use facebook graph api to list a page feed without authorizing APP

I want to access next
graph.facebook.com/pagename/feed/
but I don't want the app to ask the users for permissions, since this information is public available. Is it somehow posible? Until now what I get is:
fbtrace_id
"G69vv730PRn"
message
"(#200) The user hasn't authorized the application to perform this action"
type
"OAuthException"
With an access token generated by explorer.
What I want to do is next:
A user input the page name or id, retrieve last posts, and then for each post retrieve likes and comments.
I mean can't I do something like:
http://graph.facebook.com/v2.7/pagename
and get page information?

Use Facebook API to get a user's public feed (without up-to-date user access_token)

I've seen several questions regarding this topic in stackoverflow, but I could not find a bottom-line answer to this question.
I have a Facebook app.
I have a website to which users register using their FB account.
I would like to be able to get public posts from users' feeds using Facebook's API when the feeds update, even when the users are not logged into FB or into my website.
I was able to successfully subscribe to FB real-time updates.
I was able to see a user's public posts in http://www.facebook.com/<uid>/feed.
I tried to access https://graph.facebook.com/<uid>/feed - I got "An access token is required to request this resource.".
So I created an app access_token (using https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id=APP_ID&client_secret=APP_SECRET).
I then tried to supply the app access_token I received when accessing the user's feed: https://graph.facebook.com/<uid>/feed?access_token=APP_ACCESS_TOKEN.
This time, I didn't get an OAUTH error, but just an empty JSON array: "{ "data": [ ] }"
The user in question gave the following permissions to my app: "email,read_stream,export_stream" (using the scope parameter in the FB.login API call).
At the moment it seems to me that the only way to get a user's feed via API is to wait for the user to log back into my website, get a user access_token, and only then make the calls.
I would appreciate it if anyway could confirm the above conclusion, or even better: let me know what I'm doing wrong...
Thanks!

As a "normal Facebook user" I can access the friends of a friend of mine. But why do I need an "access token" to get the SAME INFO through graph api?

Don't think as developer yet. I'm a Facebook "normal user" and I'm logged. Then I access a friend 'X' profile. As a friend, I can see all the friends of friend X through this url:
https://www.facebook.com/friendx/friends
Fine... I can close the browser and, when I open it again, I can access the same url and see my friend's friends. And it's fine, because there is a cookie telling the server who I am.
But now, I'm still logged and I wanna retrieve all the friends of friend X throught graph api request, so i access this url:
https://graph.facebook.com/friendx/friends
And the error is, according to the documentation, expect:
An access token is required to request this resource.
I can't understand why facebook needs an access token. I'm logged in both cases. That cookie, in the second situation, is useless when I try to access the same information through graph api request.
What I wanna mean is: I don't wanna parse a whole html page to know who are friends of my friend. Parsing json is much easily.
The Facebook API requires authentication from the user to make that GET request, therefore you need an access_token saying that the user gave permission for you to access their friends list.
You cannot get an access_token from your cookies as it has to be generated via the API after the user approves your app.
If you want to test the graph API consider using the Graph API Explorer to generate an access token and generate the request but you should not use this as a solution to your answer.
consider reading the facebook documentation on access_tokens to further understand how the facebook API and authentication work.
The facebook GraphAPI doesnt allow us to collect the data which belongs to someone else. As you said you can access the friend's friend but at that time you are not collecting data for personal use, so that is allowed. That data is public so you can access, but I certainly doubt that they do allow us to access that data through GraphAPI or any other API. Also scrapping Facebook data is not against the facebook policies.

Possible bug with test users and page access tokens

Possible Facebook bug: First I am posting here because for some reason the button to create a bug never appears when I go to https://developers.facebook.com/bugs !
Facebook test users don't behave exactly like real users: If you make a call to graph api fql using a page access token to retrieve basic info for the user like name etc the api returns nothing. The reason why I am using a page access token is because I am making a batch request which requires the page access token. Real users users return the basic info like name with the page access token but test user don't.
Thanks

Facebook graph API won't return friends work history

Let's rule out the obvious...
My Facebook app requests the following permissions: user_work_history, friends_work_history
...so the usual suspect (insufficient permissions) isn't the source of my problem.
ISSUE:
The following graph api call works perfectly: /me/friends?fields=name,work
I get back names, ids, work history, etc. Just like you'd expect.
BUT
When I replace the /me with the user id of one my apps users (who has already authorized the app), I can only see names and ids (no work or education fields).
Why is this?
The reason why, is the access token you are using is not the access token belonging to the user you want to look at. Check out your token in the linter tool (https://developers.facebook.com/tools/lint) and see who it belongs to.
When you do get a user access token for that individual, then you can use it to get their friends. You wont need to specify /{userid}/friends?fields=name,work (although you could), just /me/friends?fields=name,work since the access token belongs to that user id.