Exemplo n.º 1
0
    $operation = new \AdWords\cm\v201109\AdGroupAdOperation();
    $operation->operand = $adGroupAd;
    $operation->operator = 'REMOVE';
    $operations = array($operation);
    // Make the mutate request.
    $result = $adGroupAdService->mutate($operations);
    // Display result.
    $adGroupAd = $result->value[0];
    printf("Ad with id '%s' was deleted.\n", $adGroupAd->ad->id);
}
try {
    $iniFilename = __DIR__ . '/../../example.ini';
    if (file_exists($iniFilename)) {
        $ini = parse_ini_file($iniFilename, true);
        $userSettings = $ini['user'];
    } else {
        die("Ini file not found\n");
    }
    $user = new \AdWords\User();
    $user->setEmail($userSettings['email']);
    $user->setPassword($userSettings['password']);
    $user->setAuthToken($userSettings['authToken']);
    $user->setClientId($userSettings['clientId']);
    $user->setDeveloperToken($userSettings['developerToken']);
    printf("AuthToken: %s\n", $user->getAuthToken());
    printf("ClientId: %s\n", $user->getClientId());
    // Run the example.
    deleteAdExample($user, $adGroupId, $adId);
} catch (Exception $e) {
    printf("An error has occurred: %s\n", $e->getMessage());
}
    return;
}
// Register autoloader for the library.
require_once __DIR__ . '/../../../src/AdWords/Autoloader.php';
\AdWords\Autoloader::register();
try {
    $iniFilename = __DIR__ . '/../../example.ini';
    if (file_exists($iniFilename)) {
        $ini = parse_ini_file($iniFilename, true);
        $userSettings = $ini['user'];
    } else {
        die("Ini file not found\n");
    }
    // Get AdWordsUser from credentials in "../auth.ini"
    // relative to the AdWordsUser.php file's directory.
    $user = new \AdWords\User();
    $user->setEmail($userSettings['email']);
    $user->setPassword($userSettings['password']);
    $user->setAuthToken($userSettings['authToken']);
    printf("AuthToken: %s\n", $user->getAuthToken());
    $soapClientFactory = new \AdWords\SoapClientFactory($user, null, false);
    // WARNING: CreateAccountService doesn't work on https://adwords-sandbox.google.com
    //$soapClientFactory->setServer('https://adwords-sandbox.google.com');
    /** @var \AdWords\mcm\v201109\CreateAccountService $createAccountService */
    $createAccountService = $soapClientFactory->generateSoapClient('CreateAccount');
    // Create account.
    $account = new \AdWords\mcm\v201109\Account();
    $account->currencyCode = 'EUR';
    $account->dateTimeZone = 'Europe/London';
    // Create operation.
    $operation = new \AdWords\mcm\v201109\CreateAccountOperation();
            foreach ($page->entries as $campaign) {
                printf("Campaign with name '%s' and id '%s' was found.\n", $campaign->name, $campaign->id);
            }
        } else {
            print "No campaigns were found.\n";
        }
        // Advance the paging index.
        $selector->paging->startIndex += PAGE_SIZE;
    } while ($page->totalNumEntries > $selector->paging->startIndex);
}
try {
    $iniFilename = __DIR__ . '/../../example.ini';
    if (file_exists($iniFilename)) {
        $ini = parse_ini_file($iniFilename, true);
        $userSettings = $ini['user'];
    } else {
        die("Ini file not found\n");
    }
    $user = new \AdWords\User();
    $user->setEmail($userSettings['email']);
    $user->setPassword($userSettings['password']);
    $user->setAuthToken($userSettings['authToken']);
    $user->setClientId($userSettings['clientId']);
    $user->setDeveloperToken($userSettings['developerToken']);
    printf("AuthToken: %s\n", $user->getAuthToken());
    printf("ClientId: %s\n", $user->getClientId());
    // Run the example.
    getCampaignsExample($user);
} catch (Exception $e) {
    printf("An error has occurred: %s\n", $e->getMessage());
}
    if (array_key_exists((string) $account->customerId, $links)) {
        foreach ($links[(string) $account->customerId] as $childLink) {
            if ($childAccount = $accounts[(string) $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 {
    $iniFilename = __DIR__ . '/../../example.ini';
    if (file_exists($iniFilename)) {
        $ini = parse_ini_file($iniFilename, true);
        $userSettings = $ini['user'];
    } else {
        die("Ini file not found\n");
    }
    $user = new \AdWords\User();
    $user->setEmail($userSettings['email']);
    $user->setPassword($userSettings['password']);
    $user->setAuthToken($userSettings['authToken']);
    $user->setDeveloperToken($userSettings['developerToken']);
    printf("AuthToken: %s\n", $user->getAuthToken());
    // Run the example.
    getAccountHierarchyExample($user);
} catch (Exception $e) {
    printf("An error has occurred: %s\n", $e->getMessage());
}