Open HelplessMan opened 5 years ago
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']);
dd($subAccounts,$subAccounts['subAccounts']);
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 ] }
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
response:
There is a weird problem if I dump
dd($subAccounts,$subAccounts['subAccounts']);
response: