2

I created an app and added 16 test users in the App interface. I made it so 5 of those users weren't affiliated with the app and the other 11 were. I had one user become friends with the other 15. I then tried various ways to retrieve a listing of a given user's friends.

https://graph.facebook.com/{RANDOM USER ID ON OUR APP}/friends?fields=installed&access_token={OUR APP ACCESS TOKEN}&format=json

yielded this

{
   "error": {
      "message": "(#604) Can't lookup all friends of {RANDOM USER ID ON OUR APP}. 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
   }
}

FQL wasn't any better.

https://graph.facebook.com/fql?q=SELECT+uid2+FROM+friend+WHERE+uid1={RANDOM USER ID ON OUR APP}&access_token={OUR APP ACCESS TOKEN}&format=json

yield this

{
   "error": {
      "message": "A user access token is required to request this resource.",
      "type": "OAuthException",
      "code": 102
   }
}

I understand what's happening here. These calls are attempting to retrieve all friends of the user in question and as some users aren't members of the app I'm not allowed to make this call. So I need to make a call that allows me to get just the friends that are members of the app if that's possible.

Preston Crawford
  • 330
  • 1
  • 5
  • 15
  • In both the Graph and FQL examples you gave you failed to specify **which** user you are talking about... The endpoint for friends should be `/USER_ID/friends...` and the FQL equivalent would be `SELECT+uid2+FROM+friend+WHERE+uid1=USER_ID`. If you are talking about the currently logged in user then you can replace `USER_ID` with `me()`. – Lix Jul 12 '12 at 20:26
  • Sorry about that. I made a mistake when I was formatting my question and trying to obfuscate the IDs we used there. I fixed it above. – Preston Crawford Jul 12 '12 at 20:33
  • 3
    You need to use the **user access token** to gain access to the users information. The app access token is to perform actions on behalf of the application... – Lix Jul 12 '12 at 20:34

1 Answers1

2

You need to use the user access token to gain access to the users information.

Btw, you cant do that anymore in 2.0

Take a look here.

Community
  • 1
  • 1
Vitor
  • 523
  • 2
  • 4
  • 28