2013-08-01 127 views
0
$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'开头的广告系列。Adwords PHP API withCondition无法正常工作

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

我不知道我是否有语法错误,我使用这个页面作为参考https://developers.google.com/adwords/scripts/docs/reference/adwordsapp_campaignselector#withCondition_1

的错误我得到的回复是:出现了一个错误

:报告下载失败。底层错误是 Type ='ReportDownloadError.INVALID_REPORT_DEFINITION_XML',触发器= '无效的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”:分页}' 是 预期“,FieldPath会= ''。

由于提前,

詹姆斯

回答

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');