-1

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.

  • possible duplicate of [Get a list of Friends of a Friend on facebook](http://stackoverflow.com/questions/1330123/get-a-list-of-friends-of-a-friend-on-facebook) – Igy Jan 14 '14 at 18:53
  • Igy, Maybe I expressed wrong. I edited the question. Read it again, please. – Jhones Santos Jan 14 '14 at 21:19

2 Answers2

2

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.

Crawdingle
  • 790
  • 1
  • 8
  • 23
  • Maybe I expressed wrong. I edited the question. Please, read it again. – Jhones Santos Jan 14 '14 at 21:20
  • "I wanna know what you think about it and if there is a way to get that information with graph api request without access token." There is no easy possible way without the access code. – Crawdingle Jan 15 '14 at 01:52
  • 1
    This answer is correct, the API needs you to provide an access token which authorises you to access data on behalf of a specific user; being logged into Facebook in your web browser is not equivalent – Igy Jan 15 '14 at 01:53
  • Guys, You didn't get what I'm really trying to say. Forget about this part: "I wanna know what you think about it and if there is a way to get that information with graph api request without access token.". And, please, read again the whole post. You'll get why my question makes senses. – Jhones Santos Jan 15 '14 at 04:45
0

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.

icm
  • 274
  • 1
  • 5
  • 11