Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Graph API tells me an object doesn't exist while it does

I'm starting to create a little app to get the names associated with Facebook IDs for a bigger project. I just started to use the Facebook API and it's giving me weird results. Most of the time, everything works fine. I use this code (I'm using Python, but that doesn't really matter here since it's the Facebook API that is causing the problem) :

def downloadString(url, params):
    cookie = {}
    data = requests.get(url,cookies=cookie,params=params)
    return data.text
url = "https://graph.facebook.com/v2.6/"  
id = "afriendidhere"
dl = basics.downloadString(url + id, {"access_token":accesstoken})
res = json.loads(dl)

As I said, most of the time, it works just fine, giving me the name of the given person. Though, for two people in my friends list, I get the following message :

{
  "error": {
    "message": "Unsupported get request. Object with ID 'theid' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
    "type": "GraphMethodException",
    "code": 100,
    "fbtrace_id": "FTfrh78XjW/"
  }
}

I don't understand why. The person with this id does exist, since I can access the page http://facebook.com/messages/theid and it's giving me my conversation history with this user. It's always the same people who cause the error, everyone else works perfecty.

Does anyone know why ?

like image 971
Thomas Kowalski Avatar asked Jun 19 '16 12:06

Thomas Kowalski


1 Answers

You are only supposed to get data from users who authorized your App. Authorized them, get their App Scoped ID and name with the /me endpoint. More information: https://developers.facebook.com/docs/graph-api/reference/v2.6/user

like image 149
andyrandy Avatar answered Nov 05 '22 13:11

andyrandy