0

我正在使用 php 来获取每个关键字在 Google adwords 中的广告系列的总数。我已经设置了所有但问题是我正在下载的报告不包含数据。

我获取报告的功能:

function DownloadKeywordReport(AdWordsUser $user, $filePath, $keyword_id) 
    {
        // Load the service, so that the required classes are available.
        $user->LoadService('ReportDefinitionService');

        // Create selector.
        $selector = new Selector();
        $selector->fields = array('Clicks', 'Id', 'ConversionValue');

        // Filter out deleted criteria.
        //$selector->predicates[] = new Predicate('Status', 'NOT_IN', array('DELETED'));
        $selector->predicates[] = new Predicate('Id', 'IN', array($keyword_id));


        // Create report definition.
        $reportDefinition = new ReportDefinition();
        $reportDefinition->selector = $selector;
        $reportDefinition->reportName = 'Criteria performance report #' . uniqid();
        //$reportDefinition->dateRangeType = 'CUSTOM_DATE';
        $reportDefinition->dateRangeType = 'LAST_7_DAYS';
        $reportDefinition->reportType = 'KEYWORDS_PERFORMANCE_REPORT';
        $reportDefinition->downloadFormat = 'XML';

        // Exclude criteria that haven't recieved any impressions over the date range.
        $reportDefinition->includeZeroImpressions = FALSE;

        // Set additional options.
        $options = array('returnMoneyInMicros' => FALSE);

        ReportUtils::DownloadReport($reportDefinition, $filePath, $user, $options);
        printf("Report with name '%s' was downloaded to '%s'.\n",
        $reportDefinition->reportName, $filePath);


        $doc = new DOMDocument();
        $doc->loadXML(file_get_contents($filePath));
        $xp = new DOMXPath($doc);
        $q = $xp->query("/report/table/row/@cost");

    }

生成的xml报告是

<report>
      <report-name name="Criteria performance report #559f659c928ac"/><date-range date="Jul 3, 2015-Jul 9, 2015"/>
      <table>
        <columns>
          <column name="clicks" display="Clicks"/>
          <column name="keywordID" display="Keyword ID"/>
          <column name="totalConvValue" display="Total conv. value"/></columns>
</table>
</report>

如果我使用 google adsense 预览工具,它不会在此处显示我的添加。我做错了什么或者测试帐户有什么可能性?

4

1 回答 1

0

测试帐户不会累积展示次数(因为没有显示广告),因此您需要设置

$reportDefinition->includeZeroImpressions = TRUE;

于 2015-07-13T17:25:39.977 回答