* @param Link $link the link used to reach this account * @param array $accounts a map from customerId to account * @param array $links a map from customerId to child links * @param int $depth the depth of the current account in the tree */ function DisplayAccountTree($account, $link, $accounts, $links, $depth) { print str_repeat('-', $depth * 2); printf("%s, %s, %s\n", $account->customerId, !empty($link->descriptiveName) ? $link->descriptiveName : $account->login, isset($link) ? $link->typeOfLink : 'N/A'); if (array_key_exists($account->customerId, $links)) { foreach ($links[$account->customerId] as $childLink) { $childAccount = $accounts[$childLink->clientId->id]; DisplayAccountTree($childAccount, $childLink, $accounts, $links, $depth + 1); } } } // Don't run the example if the file is being included. if (__FILE__ != realpath($_SERVER['PHP_SELF'])) { return; } try { // Get AdWordsUser from credentials in "../auth.ini" // relative to the AdWordsUser.php file's directory. $user = new AdWordsUser(); // Log every SOAP XML request and response. $user->LogAll(); // Run the example. GetAccountHierarchyExample($user); } catch (Exception $e) { printf("An error has occurred: %s\n", $e->getMessage()); }
/** * Tests GetAccountHierarchyExample. */ public function testGetAccountHierarchyExample() { GetAccountHierarchyExample($this->mccUser); }