Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.
Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/
request_error: Resource name 'customers/1234567890' is malformed: expected 'customers/{customer_id}/customerClients/{part_1}'.
What is customerClients nd what I neeed to pass?
Thanks,
function getAllCustomers() {
$customerServiceClient = $googleAdsClient->getCustomerServiceClient();
echo "<pre>";
// Issues a request for listing all accessible customers.
$accessibleCustomers = $customerServiceClient->listAccessibleCustomers();
print 'Total results: ' . count($accessibleCustomers) . PHP_EOL;
// Iterates over all accessible customers' resource names and prints them.
foreach ($accessibleCustomers->getResourceNames() as $resourceName) {
/** @var string $resourceName */
printf("Customer resource name: '%s'%s", $resourceName, PHP_EOL);
$customer = $customerServiceClient->getCustomer($resourceName);
$customerId = ($customer->getId() != '') ? $customer->getId()->getValue() : '';
$this->getCustomersFromCustomerId($customerId);
}
}
function getCustomersFromCustomerId($customerId) {
$googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient();
// Creates a query that retrieves all campaigns.
$query = 'SELECT customer_client.resource_name,
customer_client.client_customer,
customer_client.level,
customer_client.hidden,
customer_client.level
FROM customer_client';
// Issues a search request by specifying page size.
$response = $googleAdsServiceClient->search($customerId, $query, ['pageSize' => self::PAGE_SIZE]);
// Iterates over all rows in all pages and prints the requested field values for
// the campaign in each row.
foreach ($response->iterateAllElements() as $googleAdsRow) {
//print_r($googleAdsRow);
//"Customer with ID '%s', ResourceName '%s', Level '%s' and isHidden '%s' was found.",
printf(
"Customer ResourceName '%s', isHidden %d, Level %d and clientCustomer '%s' was found.%s", $googleAdsRow->getCustomerClient()->getResourceName(), $googleAdsRow->getCustomerClient()->getHidden()->getValue(), $googleAdsRow->getCustomerClient()->getLevel()->getValue(), $googleAdsRow->getCustomerClient()->getClientCustomer()->getValue(), PHP_EOL
);
}
}