Hello Darshan,

Yes, It is exactly same issue I was refer to.
Old Adwords API is quick to get those info while for current API I need to 
do as many as 3 API calls required to get 1 MCC account info.
Imaging If you had a large size account, it not only delay the response but 
also use unnecessary resources.

I had try this to get the details, In my case so many accounts were hidden 
but still I need to gone through each of them due to nature of the API




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
        );
    }
}


Thanks,




On Saturday, 16 March 2019 23:13:29 UTC+5:30, Darshan Pradhan wrote:
>
> I had similar issue and the thread is in here 
> <https://groups.google.com/forum/#!profile/adwords-api/APn2wQccp4lhOazhNRuNy1PYFdZ6RvybQi0bhMVUw_ieOoIQIIWdscXNsdehba_qTH5vyxp16dQN/adwords-api/ZqvA-qZrI9Y/CTsJCmvyAAAJ>
> .
>
> TLDR, the listAccessibleCustomers pull all the active and inactive directly 
> accessible accounts. 
> You should be able to grab the indirectly accessible customer(acounts 
> under MCC) using the query provide by Google Team which is "select *  from 
> customer_client" .
>
> The problem i ran into was the customer_client only returns the 
> customer_clients account id(extract from resource_name) which is not very 
> meaningful since I needed to present the user's account by name. 
> So for each account i get back for the customer_client I had to go and 
> make a customerServiceClient.getCustomer(resourceName) call, which would 
> give me the details I needed( other attributes such as is_manager, 
> test_account etc). 
> With above solution one Caveat is that if you have to make an api call for 
> each account you will have to implement a delay between the call which 
> sometimes will still results in resource_exhaustion which is not very easy 
> to handle in new Ads API. 
>
> There was not easy way to do this so to retrieve the details of the 
> customer I had to fall back to old adwords api to pull the customer clients 
> details (managedCustomers resource). The old adwords api only return active 
> accounts thought so my solution was to 
> mash the result of both old adwords api and new ads api for now until new 
> Ads words provides a way to pull the clients accounts name from the 
> customer_client resource. 
>
>
>
> On Saturday, March 16, 2019 at 6:28:54 AM UTC-4, cv wrote:
>>
>> Hello Bharani,
>>
>> Thanks, I am able to use query, but my main concern remains same.
>>
>> As I said Out of few accounts accessible under my MCC I can only get few 
>> of them so how would I know that or my client know that which account he 
>> has to link, since I have not all listed.
>>
>> I can query that and find the account but that to required customerID, 
>> how would that I can have?
>>
>>
>> Thanks,
>>
>>
>>
>> On Friday, 15 March 2019 21:44:13 UTC+5:30, googleadsapi-forumadvisor 
>> wrote:
>>>
>>> Hello Chirag, 
>>>
>>> I have raised this concern about the customer_client fields in the query 
>>> builder to the team. Could you try with the query below and let me know if 
>>> you're having an issue?
>>>
>>> $query = 'SELECT customer_client.resource_name, customer_client.level 
>>> FROM customer_client';
>>>
>>> Thanks,
>>> Bharani, Google Ads API Team
>>>
>>> =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
>>> Also find us on our blog and discussion group:
>>>     http://googleadsdeveloper.blogspot.com/search/label/adwords_api
>>>     https://developers.google.com/adwords/api/community/
>>> =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
>>>
>>> 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.
>>>
>>> Take Survey 
>>> <https://support.google.com/google-ads/contact/survey_transactional?caseid=2-1709000026033&hl=en&ctx=1>
>>>
>>> Also find us on our blog and discussion group:
>>> http://googleadsdeveloper.blogspot.com/search/label/adwords_api
>>> https://developers.google.com/adwords/api/community/
>>>
>>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/7c1afa79-087c-4f29-a3f6-2ebe45260aa3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
  • ListAcc... cv
    • RE... googleadsapi-forumadvisor via AdWords API and Google Ads API Forum
      • ... cv
        • ... googleadsapi-forumadvisor via AdWords API and Google Ads API Forum
          • ... cv
          • ... cv
            • ... googleadsapi-forumadvisor via AdWords API and Google Ads API Forum
              • ... cv
                • ... Darshan Pradhan
                • ... cv
                • ... googleadsapi-forumadvisor via AdWords API and Google Ads API Forum
                • ... cv
    • Re... Costantin
      • ... googleadsapi-forumadvisor via AdWords API and Google Ads API Forum
        • ... jordan
          • ... googleadsapi-forumadvisor via AdWords API and Google Ads API Forum

Reply via email to