Hi everyone,
I wrote a program using the Google Adwords API want to retrieve the campaign information for a specific customer client ID.
This is my code.
<?php
require_once dirname(dirname(__FILE__)) . "/init.php";
function GetCampaignsTest(AdWordsUser $user) {
$user->SetClientCustomerId('XXX-XXX-XXX');
$campaignService =
$user->GetService("CampaignService", ADWORDS_VERSION);
$selector = new Selector();
$selector->fields = array('Id', 'Name', 'Status');
$selector->ordering[] = new OrderBy('Name', 'ASCENDING');
$selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
do {
$page = $campaignService->get($selector);
if (isset($page->entries)) {
foreach ($page->entries as $campaign) {
echo $campaign->id . ': ' . $campaign->name . ' ' . $campaign->status . "\n";
}
} else {
print "No campaigns were found.\n";
}
$selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
} while ($page->totalNumEntries > $selector->paging->startIndex);
}
try {
$user = new AdWordsUser();
$user->LogAll();
GetCampaignsTest($user);
} catch (Exception $e) {
printf("An error has occurred: %s\n", $e->getMessage());
}
?>
The resutls ...
"No campaigns were found."
Why campaigns is were not found?
What is wrong with it?
Notice:
The "SetClientCustomerId" is not MCC account. It is using the customer client ID(CID) that was allocated to the individual.
Of course, the campaign when viewed in Google Adwords management screen of the customer client ID has been set.
Google AdWords API v201509 use.