Howdy,
I have notices two issues related with googleads-php-lib.
- There is no possibility to query alert service from php library passing clientId, because exception is thrown (in response you can notice clientId = 0 - why?).
- There is no possibility to query alert service from MCC account with customers, that authorized the app via OAuth2.
I have an app that authorizes users via OAuth2 and uses MCC's user developer key. Everyone who allows application to get into their data, allows to generate on-demand reports, browse the ads configuration etc. But in AlertService there is no entries. The
example also returns no entries. My code:
$ADWORDS_VERSION = 'v201406';
// Get the service, which loads the required classes.
$service = $client->GetService('AlertService', $ADWORDS_VERSION);
$clientId = (int) 'ClientIdWithoutDashes';
//$clientId = 'ClientIdWithoutDashes'; // i have tried this also...
$alertQuery = new \AlertQuery();
$alertQuery->clientSpec = "ID_LIST";
$alertQuery->clientCustomerIds = array($clientId);
$alertQuery->filterSpec = 'ALL';
$alertQuery->types = array('ACCOUNT_BUDGET_BURN_RATE','ACCOUNT_BUDGET_ENDING',
'ACCOUNT_ON_TARGET','CAMPAIGN_ENDED','CAMPAIGN_ENDING',
'CREDIT_CARD_EXPIRING','DECLINED_PAYMENT',
'MANAGER_LINK_PENDING','MISSING_BANK_REFERENCE_NUMBER',
'PAYMENT_NOT_ENTERED','TV_ACCOUNT_BUDGET_ENDING','TV_ACCOUNT_ON_TARGET',
'TV_ZERO_DAILY_SPENDING_LIMIT','USER_INVITE_ACCEPTED',
'USER_INVITE_PENDING','ZERO_DAILY_SPENDING_LIMIT');
$alertQuery->severities = array('GREEN', 'YELLOW', 'RED');
$alertQuery->triggerTimeSpec = 'ALL_TIME';
// Create selector.
$selector = new \AlertSelector();
$selector->query = $alertQuery;
// Create paging controls.
$selector->paging = new \Paging(0, \AdWordsConstants::RECOMMENDED_PAGE_SIZE;);
$result = [];
$i = 0;
do {
// Make the get request.
$page = $service->get($selector);
// Display results.
if (isset($page->entries)) {
foreach ($page->entries as $entry) {
$result[] = $entry;
}
} else {
// No entries were found.
}
// Advance the paging index.
$selector->paging->startIndex += $itemsPerPage;
}
while ($page->totalNumEntries > $selector->paging->startIndex);
return $result;
I have tried passing
$clientId as integer, as Paul Matthews (AdWords API Team)
written and as string with and without dashes.
I am receiving exception:
[AlertError.INVALID_CLIENT_ID_SELECTED @ selector.query.clientExternalCustomerIds[0]]
In respons you can see that customerId is equal zero, while I have passed an value...
While I am using this method:
$alertQuery = new \AlertQuery();
$alertQuery->clientSpec = 'ALL';
$alertQuery->filterSpec = 'ALL';
$alertQuery->types = array('ACCOUNT_BUDGET_BURN_RATE','ACCOUNT_BUDGET_ENDING',
'ACCOUNT_ON_TARGET','CAMPAIGN_ENDED','CAMPAIGN_ENDING',
'CREDIT_CARD_EXPIRING','DECLINED_PAYMENT',
'MANAGER_LINK_PENDING','MISSING_BANK_REFERENCE_NUMBER',
'PAYMENT_NOT_ENTERED','TV_ACCOUNT_BUDGET_ENDING','TV_ACCOUNT_ON_TARGET',
'TV_ZERO_DAILY_SPENDING_LIMIT','USER_INVITE_ACCEPTED',
'USER_INVITE_PENDING','ZERO_DAILY_SPENDING_LIMIT');
$alertQuery->severities = array('GREEN', 'YELLOW', 'RED');
$alertQuery->triggerTimeSpec = 'ALL_TIME';
I am receiving no alerts, while a few exists.
I have also tried set customerId in client:
$client->SetClientCustomerId( ... ); // as in reporting service, wherethis method works
What's going on?