Adwords PHP API withCondition不起作用

时间:2013-08-01 15:20:24

标签: php api google-adwords

$user->LoadService("ReportDefinitionService");

$selector = new Selector();
$selector->fields = $report["fields"];
$selector->dateRange = new DateRange($api_date, $api_date);
$selector->withCondition = "Name STARTS_WITH 'CTC'";

$reportDefinition = new ReportDefinition();
$reportDefinition->reportName = 'my_made_up_name_' . time();
$reportDefinition->dateRangeType = "CUSTOM_DATE";
$reportDefinition->reportType = $report["type"];
$reportDefinition->downloadFormat = "GZIPPED_CSV";
$reportDefinition->selector = $selector;

我正在尝试限制我在报告中返回的广告系列,以便我只能获得以“CTC”开头的广告系列。

$selector->withCondition = "Name STARTS_WITH 'CTC'";

我不确定我的语法是否错误我将此页面用作参考https://developers.google.com/adwords/scripts/docs/reference/adwordsapp_campaignselector#withCondition_1

我要回的错误是:

  

发生错误:报告下载失败。潜在的错误是   Type ='ReportDownloadError.INVALID_REPORT_DEFINITION_XML',Trigger =   '无效的ReportDefinition Xml:cvc-complex-type.2.4.a:内容无效   被发现以元素'withCondition'开头。之一   “{ “https://adwords.google.com/api/adwords/cm/v201306”:订货,   “https://adwords.google.com/api/adwords/cm/v201306”:paging}'是   预期。',FieldPath =''。

提前致谢,

詹姆斯

1 个答案:

答案 0 :(得分:0)

$selector = new Selector();
$selector->fields = $report["fields"];
$selector->dateRange = new DateRange($api_date, $api_date);
//$selector->withCondition = "Name STARTS_WITH 'CTC'";
$selector->predicates[] = new Predicate('CampaignName', 'STARTS_WITH', 'CTC');