[英]Is there DEVICE_PERFORMANCE_REPORT in Google AdWords API
[英]Adwords api report without download
我正在使用Adwords API,我已經可以下載以下報告:所有帶有展示次數,陳詞濫調,ctr,轉化次數等的關鍵字...
問題是,當用戶設置日期范圍時,我需要在我們的網絡工具上顯示此報告。
現在我這樣做:用戶選擇開始日期01/09/2014結束日期15/09/2014,我調用Adwords Api,下載CSV,解析它,然后在屏幕上顯示結果,但這種方式不是最佳,我想知道如何調用API並“獲取結果”,獲取XML或JSON而無需下載文件。
可能嗎??
我找到的唯一方法是調用CampaignService類..獲取所有廣告系列,然后為每個廣告系列調用AdgroupService以獲取所有廣告組,然后是關鍵字....這真的不切實際。
我該怎么做?
非常感謝你。
它出現在最近版本的libary中,它們創建了一個函數(getAsString()),所以我們可以實現這個:
$reportDownloader = new ReportDownloader($session);
$reportDownloadResult = $reportDownloader->downloadReport($reportDefinition);
//Normal way of downloading to file
//$reportDownloadResult->saveToFile($filePath);
//printf("Report with name '%s' was downloaded to '%s'.\n",
// $reportDefinition->getReportName(), $filePath);
//New way by calling getAsString();
$reportAsString = $reportDownloadResult->getAsString();
echo $reportAsString;
關於將null作為$ filePath傳遞的舊建議不再有效。
是的,您可以在不下載文件的情況下獲取XML。 只需在調用ReportUtils::DownloadReport()
時將$path
設置$path
Null
,它就會返回響應而不將其保存到文件中。
AdWords API庫(自v201506起)允許您將download_format設置為CSVFOREXCEL,CSV,TSV,XML,GZIPPED_CSV或GZIPPED_XML之一。 遺憾的是,即使您要求下載報告數據(而不是文件),也不支持JSON。
$reportAsString = $reportDownloadResult->getAsString();
$xml = simplexml_load_string($reportAsString);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.