我正在使用 Google AdWords PHP API 从我们的帐户访问统计信息。但是,我通过 api 从统计数据中得到了一些非常奇怪的读数。我正在尝试访问个人广告或广告组的统计信息。然而,返回的统计数据与客户中心的数据相差甚远。我正在使用的代码:
$user->SetClientCustomerId($clientId);
$adService = $user->GetService("AdGroupAdService", ADWORDS_VERSION);
$selector = new Selector();
$selector->fields = array("Id", "Name", "Clicks", "Impressions", "Cost");
$selector->predicates[] = new Predicate("AdGroupId", "IN", array($adGroupId));
$selector->dateRange = $dateRange;
$selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
do {
// Make the get request.
$page = $adService->get($selector);
if (isset($page->entries)) {
foreach ($page->entries as $ad) {
$newLineObject->adName = $ad->name;
$newLineObject->clicks = $ad->ad->AdStats->clicks;
$newLineObject->impressions = $ad->adStats->impressions;
$newLineObject->cost = $ad->ad->AdStats->cost->microAmount/ AdWordsConstants::MICROS_PER_DOLLAR;
}
}
else {
print "No matching ads were found.\n";
}
$selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
} while ($page->totalNumEntries > $selector->paging->startIndex);
当我打印结果时,我得到的数字比客户中心显示的要大得多。例如,对于一个特定的广告,API 报告了 2.000.000 次展示,而客户中心显示了 56.000 次。
我究竟做错了什么?