Why I get campaign and ad_group status is always UNSPECIFIED?

80 views
Skip to first unread message

Len Han/韩莱恩

unread,
Feb 8, 2021, 2:13:52 AM2/8/21
to Google Ad Manager API Forum
Hi,
I try to use google ads api, and when i get the campaign and ad_group status is always UNSPECIFIED. but in the google ads UI, it's status is ENABLED. I use update campaign function can truely change the status, but result of get campaign funciton return the status is always UNSPECIFIED. If anyone can help me, thank you so much!
get campaign function code is like this.
public function getCampaign($pageSize = null, $customerId = null, $deep = false)
{
$googleAdsClient = self::$client;
$customerId = $customerId ? : self::$ccId;

$googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient();
// Creates a query that retrieves all campaigns.
$query = 'SELECT campaign.id, campaign.name FROM campaign ORDER BY campaign.id';

//set login-customer-id in headers
if ($pageSize) {
$pageOption = ['pageSize' => $pageSize];
$options = array_merge(self::$options, $pageOption);
} else {
$options = self::$options;
}

$stream = $googleAdsServiceClient->search($customerId, $query, $options);

// Iterates over all rows in all messages and prints the requested field values for
// the campaign in each row.
$result = [];
foreach ($stream->iterateAllElements() as $key => $googleAdsRow) {
$result[$key]['id'] = $googleAdsRow->getCampaign()->getId();
$result[$key]['name'] = $googleAdsRow->getCampaign()->getName();
$result[$key]['status'] = CampaignStatus::name($googleAdsRow->getCampaign()->getStatus());
if ($deep) {
$result[$key]['adGroups'] = $this->getAdGroups($result[$key]['id'], null, true);
}
}
return $result;
}

Ad Manager API Forum Advisor Prod

unread,
Feb 8, 2021, 4:37:27 AM2/8/21
to len...@i9i8.com, google-doubleclick...@googlegroups.com

Hi,

 

This forum is intended for Ad Manager API related concerns only. Please post your concern in the Google Ads API forum for further assistance.

 

Regards,

Google Logo
Kevin Gil Soriano
Ad Manager API Team
 


ref:_00D1U1174p._5004Q2Bei50:ref
Reply all
Reply to author
Forward
0 new messages