$infoService = $user->GetService('InfoService', 'v201109_1'); // Create selector. $selector = new InfoSelector(); $selector->clientEmails = array($clientEmail); $selector->includeSubAccounts = TRUE; $selector->apiUsageType = 'UNIT_COUNT_FOR_CLIENTS'; // The date used doesn't matter, but it's best to use yesterday to avoid // timezone issues. $yesterday = date('Ymd', strtotime('-1 day')); $selector->dateRange = new DateRange($yesterday, $yesterday); // Make the get request. $info = $infoService->get($selector); // Display result. $record = $info->apiUsageRecords[0]; printf("Found record with client email '%s' and customer ID '%s'.\n", $record->clientEmail, $record->clientCustomerId); } // Don't run the example if the file is being included. if (__FILE__ != realpath($_SERVER['PHP_SELF'])) { return; } try { // Get AdWordsUser from credentials in "../auth.ini" // relative to the AdWordsUser.php file's directory. $user = new AdWordsUser(); // Log every SOAP XML request and response. $user->LogAll(); // Run the example. GetClientCustomerIdExample($user, $clientEmail); } catch (Exception $e) { printf("An error has occurred: %s\n", $e->getMessage()); }
/** * Tests GetClientCustomerIdExample. */ public function testGetClientCustomerIdExample() { // Try to find a client account with a login. $servicedAccountService = $this->user->GetService('ServicedAccountService'); $result = $servicedAccountService->get(new ServicedAccountSelector()); foreach ($result->accounts as $account) { if (isset($account->login)) { $clientEmail = $account->login; break; } } if (isset($clientEmail)) { GetClientCustomerIdExample($this->mccUser, $clientEmail); } }