Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP 400 Error when accessing Friends list in Facebook Graph API

When I access the list of my friends using the URL https://graph.facebook.com/me/friends?access_token=... I can see the list of my friends. I can do this programmatically as well.

Now, when I take the ID of any of my friends and replace it with "me" in the above URL, and paste the URL in the browser, I can see my friend's friends. I am unable to do this programmatically because it is giving me an HTTP 400 ERROR.

Does anyone know why this is possible by pasting the URL and not programmatically?

like image 719
London guy Avatar asked Jan 20 '26 23:01

London guy


1 Answers

You can not get the "friends of friends" using the facebook api.

For example, try the simple /me/friends with the Graph API Explorer, it should work fine. Then, take one of the ids there and try the same with FRIEND_ID/friends and you should get this:

{
  "error": {
    "message": "(#604) Can't lookup all friends of FRIEN_ID. Can only lookup for the logged in user or the logged in user's friends that are users of your app.", 
    "type": "OAuthException", 
    "code": 604
  }
}

The error itself is very straight forward and explains exactly what the problem is. As for why that translates into a 400 error code for you is unclear.


Edit

You can't see the "friends of friends" in the browser as well, the reason that it works for you (probably) is that the user(s) you check the friends for (USER_ID/friends) installed the app that the access token belongs to, from the way you got to that url I assume that the app is the "Test_console".

How to check? Copy the access token from the url (USER_ID/friends?access_token=xxxxx), go to the Facebook Debugger and paste the token in the text field and click "Debug", it will show you info regarding the application.

The user you checked it for probably has that app "installed", if you check it for other users you will get that error when you get to a user who does not have that app "installed".

I hope this clarifies it for you.

like image 198
Nitzan Tomer Avatar answered Jan 22 '26 20:01

Nitzan Tomer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!