質問

I trying to get user's facebook friend listing but when I try to use this code I getting error like this:

I trying via this link:

https://graph.facebook.com/me/friends?access_token=APP_ACCESS_TOKEN

{
   "error": {
      "message": "An active access token must be used to query information about the current user.",
      "type": "OAuthException",
      "code": 2500
   }
}

What I must to do fix this problem and get their friend list?

Thanks,

役に立ちましたか?

解決

You have used the APP ACCESS TOKEN in your url which can not understand the meaning of /me.

You have to use the USER ACCESS TOKEN, that will be corresponding to the user in session and then you can use /me

If you want to use the App Access Token, you have to query like this:

https://graph.facebook.com/<user-id>/friends?access_token=APP_ACCESS_TOKEN 

and that too is only valid if the <user-id> has once authorized your app.

You can read more about Access Tokens here.

他のヒント

You can generate your Token here.

And use like this with Python:

import urllib.request
import json
url = 'https://graph.facebook.com/<user>/friends?access_token=APP_ACCESS_TOKEN'
resp = urllib.request.urlopen(url).read()
data = json.loads(resp.decode('utf-8'))
for friend in data['data']:
  print (friend['name']) 
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top