Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get account sub-account tree empty #8

Open
HelplessMan opened this issue Aug 7, 2019 · 1 comment
Open

get account sub-account tree empty #8

HelplessMan opened this issue Aug 7, 2019 · 1 comment

Comments

@HelplessMan
Copy link

hello,
I want to get the sub-account tree under my current account by account id, get it according to the examples method, and respond to an empty object. In fact, the account has been bound to 7 sub accounts.

https://github.com/googleads/googleads-adsense-examples/blob/master/php-clientlib-1.x/v1.x/examples/GetAccountTree.php

        $pageToken = null;
        $optParams['maxResults'] = 500;
        $optParams['pageToken'] = $pageToken;
        $result = $this->service->accounts->listAccounts($optParams);
        $accounts = null;

        if (!empty($result['items'])) {
            $accounts = $result['items'];
            foreach ($accounts as $account) {
                $this->account_id = $account['id'];
            }
        }
        $subAccounts = $this->service->accounts->get($this->account_id, array('tree' => true));
        if (!empty($subAccounts['subAccounts'])){
            foreach ($subAccounts['subAccounts']  as $account) {
                dump($account);
            }
        }
    dd($subAccounts); 

response:

Google_Service_AdSense_Account^ {#1363
  #collection_key: "subAccounts"
  #internal_gapi_mappings: array:1 [
    "creationTime" => "creation_time"
  ]
  +creationTime: "1551266190244"
  +id: "pub-*********"
  +kind: "adsense#account"
  +name: "*********"
  +premium: false
  #subAccountsType: "Google_Service_AdSense_Account"
  #subAccountsDataType: "array"
  +timezone: "Europe/London"
  #modelData: array:1 [
    "creation_time" => "1551266190244"
  ]
  #processed: []
}

There is a weird problem if I dump dd($subAccounts,$subAccounts['subAccounts']);

response:

Google_Service_AdSense_Account^ {#1363
  #collection_key: "subAccounts"
  #internal_gapi_mappings: array:1 [
    "creationTime" => "creation_time"
  ]
  +creationTime: "1551266190244"
  +id: "pub-*********"
  +kind: "adsense#account"
  +name: "*********"
  +premium: false
  #subAccountsType: "Google_Service_AdSense_Account"
  #subAccountsDataType: "array"
  +timezone: "Europe/London"
  #modelData: array:2 [
    "creation_time" => "1551266190244"
    "subAccounts" => []
  ]
  #processed: array:1 [
    "subAccounts" => true  //  not empty
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@HelplessMan and others