如何使用 google adwords api 获取所有广告系列的详细信息?
How to get all campaigns details with google adwords api?
我可以使用 google adwords api(使用测试帐户)获取广告系列列表,我想获取每个广告系列的所有详细信息(展示次数、点击次数、预算、成本、每次点击费用、...) 使用 api,该怎么做?
试试这个:
// Get the service, which loads the required classes.
$campaignService = $user->GetService('CampaignService', ADWORDS_VERSION);
// Create selector.
$selector = new Selector();
$selector->fields = array('Id', 'Name','Impressions', 'Clicks');
$selector->ordering[] = new OrderBy('Name', 'ASCENDING');
// Create paging controls.
$selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
do {
// Make the get request.
$page = $campaignService->get($selector);
// Display results.
if (isset($page->entries)) {
foreach ($page->entries as $campaign) {
printf("Campaign with name '%s' and ID '%s' and Impressions %s was found.\n",
$campaign->name, $campaign->id,$campaign->impressions);
}
} else {
print "No campaigns were found.\n";
}
// Advance the paging index.
$selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
} while ($page->totalNumEntries > $selector->paging->startIndex);
但是出现这个错误:
An error has occurred: [SelectorError.INVALID_FIELD_NAME @ serviceSelector; trigger:'Impressions', SelectorError.INVALID
_FIELD_NAME @ serviceSelector; trigger:'Clicks']
谢谢。
对于展示次数、点击次数和转化次数等性能数据,您必须使用 ReportingService。 (您不能使用 CampaignService 查询该信息)
对于 ReportingService,您必须使用 CAMPAIGN_PERFORMANCE_REPORT.
https://developers.google.com/adwords/api/docs/appendix/reports/campaign-performance-report
我建议改用 AWQL 进行查询,因为它与 SQL 非常相似。所以如果你熟悉SQL就很容易理解了。
https://developers.google.com/adwords/api/docs/guides/awql
PHP 示例(CriteriaReport):
https://github.com/googleads/googleads-php-lib/blob/master/examples/AdWords/v201509/Reporting/DownloadCriteriaReportWithAwql.php
我可以使用 google adwords api(使用测试帐户)获取广告系列列表,我想获取每个广告系列的所有详细信息(展示次数、点击次数、预算、成本、每次点击费用、...) 使用 api,该怎么做? 试试这个:
// Get the service, which loads the required classes.
$campaignService = $user->GetService('CampaignService', ADWORDS_VERSION);
// Create selector.
$selector = new Selector();
$selector->fields = array('Id', 'Name','Impressions', 'Clicks');
$selector->ordering[] = new OrderBy('Name', 'ASCENDING');
// Create paging controls.
$selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
do {
// Make the get request.
$page = $campaignService->get($selector);
// Display results.
if (isset($page->entries)) {
foreach ($page->entries as $campaign) {
printf("Campaign with name '%s' and ID '%s' and Impressions %s was found.\n",
$campaign->name, $campaign->id,$campaign->impressions);
}
} else {
print "No campaigns were found.\n";
}
// Advance the paging index.
$selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
} while ($page->totalNumEntries > $selector->paging->startIndex);
但是出现这个错误:
An error has occurred: [SelectorError.INVALID_FIELD_NAME @ serviceSelector; trigger:'Impressions', SelectorError.INVALID
_FIELD_NAME @ serviceSelector; trigger:'Clicks']
谢谢。
对于展示次数、点击次数和转化次数等性能数据,您必须使用 ReportingService。 (您不能使用 CampaignService 查询该信息) 对于 ReportingService,您必须使用 CAMPAIGN_PERFORMANCE_REPORT.
https://developers.google.com/adwords/api/docs/appendix/reports/campaign-performance-report
我建议改用 AWQL 进行查询,因为它与 SQL 非常相似。所以如果你熟悉SQL就很容易理解了。
https://developers.google.com/adwords/api/docs/guides/awql
PHP 示例(CriteriaReport): https://github.com/googleads/googleads-php-lib/blob/master/examples/AdWords/v201509/Reporting/DownloadCriteriaReportWithAwql.php