Google Ads Api V5 How to get manage account 's customer list?

223 views
Skip to first unread message

吴文伟

unread,
Oct 22, 2020, 3:48:01 AM10/22/20
to AdWords API and Google Ads API Forum
How to get manage account 's customer list?

$googleAdsClient->get???(); 

吴文伟

unread,
Oct 22, 2020, 6:08:35 AM10/22/20
to AdWords API and Google Ads API Forum
I can using Google Adwords Api to get MCC customer list:

$managedCustomerService = $this->adwords->get($session, ManagedCustomerService::class);
$selector = new Selector();
$selector->setFields(['CustomerId','Name','CanManageClients','CurrencyCode','DateTimeZone', 'TestAccount']);
$selector->setPaging(new Paging(0, self::PAGE_LIMIT));
$customerIds = [];
do {
       $page = $managedCustomerService->get($selector);
       if ($page->getEntries() !== null) {
            $totalNumEntries = $page->getTotalNumEntries();
            foreach ($page->getEntries() as $customer) {
                $customerIds[] = $customer;
          }
      }
     $selector->getPaging()->setStartIndex($selector->getPaging()->getStartIndex() + self::PAGE_LIMIT);
} while ($selector->getPaging()->getStartIndex() < $totalNumEntries);

How to change my code using Google Ads Api? Please Help!

Google Ads API Forum Advisor Prod

unread,
Oct 22, 2020, 3:32:13 PM10/22/20
to 26338...@gmail.com, adwor...@googlegroups.com

Hi Wenwei,

Thank you for reaching out. You could use CustomerClientService.GetCustomerClient() to fetch the client customer accounts in the hierarchy. You could also query the customer_client resource to fetch the data which is recommended.

Thanks and regards,
Xiaoming, Google Ads API Team



Google Logo
Xiaoming
Google Ads API Team
 


ref:_00D1U1174p._5004Q26BFbP:ref

吴文伟

unread,
Oct 22, 2020, 9:13:33 PM10/22/20
to AdWords API and Google Ads API Forum
Thanks for answer!

For example: 
   123456 is the MCC account.
this is my code:
  
$CustomerClientServiceClient = $googleAdsClient->getCustomerClientServiceClient();
$customers = $CustomerClientServiceClient->getCustomerClient("customers/12345/customerClients/Id");

the request throw error:
   Google\ApiCore\ApiException{
          "message": "Requested entity was not found.",
          "code": 5,
          "status": "NOT_FOUND",
"details": [
{
"@type": 0,
"data": "type.googleapis.com\/google.ads.googleads.v5.errors.GoogleAdsFailure"
},
{
"@type": 0,
"data": [
{
"errorCode": {
"requestError": "BAD_RESOURCE_ID"
},
"message": "'Id' part of the resource name is invalid."
}
]
}
]
}


i donot know the parameter "resourceName" format.

can you help me,please!

吴文伟

unread,
Oct 22, 2020, 9:27:06 PM10/22/20
to AdWords API and Google Ads API Forum
i also using this code:

$googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient();
$query = "
SELECT customer_client.resource_name,customer_client.time_zone,customer_client.manager,customer_client.descriptive_name,customer_client.currency_code,customer_client.id
FROM customer_client";
$stream = $googleAdsServiceClient->search(123456,$query);
$res = $stream->iterateAllElements();

but it response nothing:
Generator Object ( ) 

 also try:
$stream = $googleAdsServiceClient->searchStream(123456,$query);
$res = $stream->iterateAllElements();

response:
 Streaming calls are not supported while using the REST transport.

i am testing on Windows 10, I don't want to use grpc.

Google Ads API Forum Advisor Prod

unread,
Oct 23, 2020, 11:39:26 AM10/23/20
to 26338...@gmail.com, adwor...@googlegroups.com

Hi Wenwei,

Thank you for reaching out. Please use this code example as a template to query the customer_client resource in the Google Ads API. 



Thanks and regards,
Xiaoming, Google Ads API Team


吴文伟

unread,
Oct 26, 2020, 9:29:53 PM10/26/20
to AdWords API and Google Ads API Forum
Thanks a lot!  It works!
12312321.png
Reply all
Reply to author
Forward
0 new messages