Alert Service returns error for specified client id. (PHP)

108 views
Skip to first unread message

Athlan

unread,
Aug 28, 2014, 9:54:06 AM8/28/14
to adwor...@googlegroups.com
Howdy,

I have notices two issues related with googleads-php-lib.
  1. 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?).
  2. 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?

Josh Radcliff (AdWords API Team)

unread,
Aug 28, 2014, 12:43:11 PM8/28/14
to adwor...@googlegroups.com
Hi,

For issue #1, the error you are encountering means that the $clientId you are passing here:

$alertQuery->clientCustomerIds = array($clientId);

Is either:

a) Not an existing AdWords customer ID, or
b) Not an AdWords customer ID to which the request's OAuth credentials has access

Regarding the second method, the AlertService only returns a subset of the alert types that you see in the UI. Which types of alerts are you seeing in the UI?

Thanks,
Josh, AdWords API Team

Athlan

unread,
Sep 1, 2014, 6:20:17 AM9/1/14
to adwor...@googlegroups.com
Thank you for reply.

On Thursday, August 28, 2014 6:43:11 PM UTC+2, Josh Radcliff (AdWords API Team) wrote:
Hi,

For issue #1, the error you are encountering means that the $clientId you are passing here:

$alertQuery->clientCustomerIds = array($clientId);

Is either:

a) Not an existing AdWords customer ID, or
b) Not an AdWords customer ID to which the request's OAuth credentials has access

I am sure about both. Customer ID exists in the system, because it is obtained from CustomerService which is accessed via valid OAuth credentials. Customer ID is a 10 digit idntifier.
 

Regarding the second method, the AlertService only returns a subset of the alert types that you see in the UI.

I have mentioned all avaliable types and severities in example.
 
Which types of alerts are you seeing in the UI?

I see two alerts from AdWOrds Account (not MCC account).

What I want is read alerts from all users that allows app via OAuth2 to access account.

Josh Radcliff (AdWords API Team)

unread,
Sep 2, 2014, 3:42:24 PM9/2/14
to adwor...@googlegroups.com
Hi,

You mentioned "I see two alerts from AdWOrds Account (not MCC account)." -- could you tell me what type of alerts they are? You can send screenshots only to me by clicking Reply to Author. As I mentioned in my prior post, though, the AlertService will not return every type of alert that you see in the UI, so you won't be able to duplicate the alert list completely using the API.

Thanks,
Josh, AdWords API Team

Josh Radcliff (AdWords API Team)

unread,
Sep 2, 2014, 5:37:55 PM9/2/14
to adwor...@googlegroups.com
Hi,

Thanks for sending over the screenshot. The alerts you highlighted are not covered by the AlertService (they don't fall into any of the categories listed for AlertService.AlertQuery#types), so you won't be able to retrieve those via the API.

Best regards,
Josh, AdWords API Team
Reply all
Reply to author
Forward
0 new messages