I am trying to access a user via the Facebook Business PHP SDK but I am getting the following error:
USER_ID
is just a placeholder for my FB ID.
FacebookAds\Http\Exception\AuthorizationException
Unknown path components: /USER_ID
The code I am using is as follows:
Again the APP_ID
, APP_SECRET
, USER_ACCESS_TOKEN
, AND USER_ID
are all placeholders but are correct in my code.
$api = Api::init(APP_ID, APP_SECRET, USER_ACCESS_TOKEN);
$api->setLogger(new CurlLogger());
$api->setDefaultGraphVersion('v13.0');
$fbuser = new \FacebookAds\Object\User(USER_ID);
die(var_dump($fbuser->getSelf()));
This is the first step of what I am trying to achieve, I need to access the ad accounts associated with a user but when I call the following:
die(var_dump($fbuser->getAdAccounts()));
I get the same error:
FacebookAds\Http\Exception\AuthorizationException
Unknown path components: /USER_ID/adaccounts
When call the graph API directly via cURL or the graph api explorer. I get a list of ad accounts as intended, so i am not sure sure what the problem is.
Example:
https://graph.facebook.com/v13.0/USER_ID/adaccounts?access_token=USER_ACCESS_TOKEN
I have seen some old issues on here relating to the version of the API being wrong, but i have tried both 13.0
and v13.0
still no luck.
Would appreciate any help as i would prefer to use the SDK then writing my own wrapper.