facebookarchive / php-graph-sdk

The Facebook SDK for PHP provides a native interface to the Graph API and Facebook Login. https://developers.facebook.com/docs/php
Other
3.18k stars 1.96k forks source link

Generated facebook access token doesn't work and gives strange error messages #1116

Open mkantautas opened 5 years ago

mkantautas commented 5 years ago

My app is set to development status and I generate a fb access token for ads_read scope permission, but when trying to use it to view ad_accounts I get this strange error:

{
  "error": {
    "message": "Unsupported get request. Object with ID 'me' 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,
    "error_subcode": 33,
    "fbtrace_id": "DqaSDwFXFKh"
  }
}

image

If I do everything the same, but switch the app to production, then I get this error:

{
  "error": {
    "message": "(#200) Requires ads_management permission to manage the object",
    "type": "OAuthException",
    "code": 200,
    "fbtrace_id": "E8a73bTfQfa"
  }
}

Which is even more bizzare, because I don't need ads_management permission to do this request: me?fields=id,name,adaccounts{name,account_id,id} , but even though I've tried adding that permission and recreated a new fb access token and then on the same attempt I got the same issue about not having ads_management permission.

Any ideas or leads how can I resolve this? I kinda feel this might be a bug on facebook end. I have tried generating a fb access token from a different fb user, which only has one fb ad account and everything worked without any issues. It seems this issue only appears with this one facebook account which has access to 400++ facebook ad accounts.

qbao96xb commented 5 years ago

I got the same issue here. Even though we grant all the right for system user, the call still fail afterwards.

oliveiracom commented 4 years ago

same problem...but if i run outside php on Insomnia it returns 200 with expected data... i'm trying with instagram graph...

oliveiracom commented 4 years ago

problem solved for me....i was using extra curl options that was returning an error....

before - returning error

$baseUrl = "https://graph.instagram.com/me";
$ch = curl_init();
$query = ['fields' => 'id, username', 'access_token'=> $user_token];

curl_setopt($ch, CURLOPT_URL, $Url);
//curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type" => "application/json; charset=UTF-8") );
curl_setopt($ch, CURLOPT_POSTFIELDS , http_build_query($query));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
$user_data = curl_exec($ch);

After - works like a charm

$Url = "https://graph.instagram.com/me?fields=id,username&access_token=". $user_token;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $Url);
$user_data = curl_exec($ch);