function getUser($masterAccount, $clientAccount) { $apilityUser = new APIlityUser(); $apilityUser->setEmail($masterAccount->user); $apilityUser->setPassword($masterAccount->password); $apilityUser->setDeveloperToken($masterAccount->developerToken); $apilityUser->setApplicationToken($masterAccount->applicationToken); $apilityUser->setClientEmail($clientAccount); return $apilityUser; }
<?php header('Content-Type: text/html; Charset=utf-8'); // include the APIlity library include 'apility.php'; // check whether APIlity can be included safely without leaving traces if (session_start()) { echo "Test Session started: " . session_id() . "<br>\n"; } else { echo "Test Session could not be started<br>\n"; } // create an APIlity user based on the information in the authentication.ini file // XOR use data from authentication.ini $apilityUser = new APIlityUser(); // XOR use data from authentication.ini // $apilityManager = new APIlityManager(); // XOR directly provide credentials // $apilityUser = new APIlityUser('*****@*****.**', 'p4ssw0rD', '*****@*****.**', 'dev3lOperT0ken', '4pplic4ti0Ntok3n'); // XOR directly provide credentials // $apilityManager = new APIlityManager('*****@*****.**', 'p4ssw0rD', 'dev3lOperT0ken', '4pplic4ti0Ntok3n'); // in case of sandbox usage, make sure the clients get created $apilityUser->getManagersClientAccounts(); ?> <html> <body> <h3>Sample use of APIlity</h3> <small>Using AdWords API <?php echo API_VERSION; ?> </small><br /> <br />
function APIlityUser($email = null, $password = null, $clientEmail = null, $developerToken = null, $applicationToken = null, $customSettingsIni = null, $customAuthenticationIni = null) { // we need to construct the superclass first, this is php-specific // object-oriented behaviour APIlityUser::APIlityManager($email, $password, $developerToken, $applicationToken, $customSettingsIni, $customAuthenticationIni); // if we have no client email, fall back to the authentication.ini file // all other fall backs for the other header fields are in the super class if (!$clientEmail) { if (isset($customAuthenticationIni) && $customAuthenticationIni) { $authenticationIni = parse_ini_file($customAuthenticationIni); $clientEmail = isset($authenticationIni['Client_Email']) ? $authenticationIni['Client_Email'] : ($clientEmail = ''); } else { $authenticationIni = parse_ini_file(dirname(__FILE__) . '/../authentication.ini'); $clientEmail = isset($authenticationIni['Client_Email']) ? $authenticationIni['Client_Email'] : ''; } } $this->setClientEmail($clientEmail); APIlityManager::setContext($this); }