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;
}