I’m having some trouble with the Facebook Marketing API. I need to read all the active campaings the current user has, in all of his ad accounts. So, the first step is to read all the ad accounts.
First, I tried what the documentation says:
// Add to header of your file
use FacebookAdsObjectAdUser;
// Add after Api::init()
$me = new AdUser('me');
$my_adaccount = $me->getAdAccounts()->current();
But the AdUser.php file doesn’t exists in the SDK.
So, I tried doing a request to the endpoint /me/adaccounts
$fb = new Facebook([
'app_id' => AppId,
'app_secret' => AppSecret,
]);
$response = $fb->get('/me/adaccounts', Token);
This throws an error saying I’m using a deprecated version of the Marketing API (but I’m using the 3.2!!). I also tried
$response = $fb->get('me?fields=adaccounts', Token);
And got the same error. Can anyone help me find another way??
PS: English is not my first language, sorry about that…
3
Answers
You can check campaigns using insights api. Type following line in explorer and see the magic
me/campaigns?fields=id,name,status,effective_status
This will give you list of 25 campaigns and you can read their status & effective status.
You can use php sdk syntax call above api url and read response.
I had the same problem. Check this solution!
Using php SDK