2013-08-01 122 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');