I am trying to get the campaign names of an ad account with the following code
$account = new AdAccount($account_id);
$cursor = $account->getCampaigns();
echo sizeof($cursor);
// Loop over objects
foreach ($cursor as $campaign) {
echo $campaign->{CampaignFields::NAME}.PHP_EOL;
}
The cursor has the correct number of campaigns but I get empty field values. Same applies when I try to get the Ad Account fields.
Does anybody know why is this happening? I am using the latest version of API (v5.0)
Thanks in advance.
You should add the field you want to request by the API in the method, as example:
Refer also to the AdAccountsCampaigns example for further details about the usage of
fields
andparams
:Hope this help