M
M
MrKMV342016-09-28 13:54:23
PHP
MrKMV34, 2016-09-28 13:54:23

How to create an ACCOUNT_PERFORMANCE_REPORT in Adwords?

I'm trying to get the cost field from the account performance report and a couple more, I created such a request, but I get an empty result.

$this->config->load('search_keys');

      $oauth2Info = array(
        'client_id' => $this->config->item('oauth_client_id'),
        'client_secret' => $this->config->item('client_secret'),
        'refresh_token' => $user_data['token']
      );

      $user = new AdWordsUser(null, null, null, null, null, $oauth2Info);
      $user->SetClientCustomerId($user_data['login']);

      $user->LoadService('ReportDefinitionService', ADWORDS_VERSION);

      // Create selector.
      $selector = new Selector();
      $selector->fields = array('Cost', 'Amount', 'AccountTimeZoneId');

      // Optional: use predicate to filter out paused criteria.
      $selector->predicates[] = new Predicate();

      // Create report definition.
      $reportDefinition = new ReportDefinition();
      $reportDefinition->selector = $selector;
      $reportDefinition->reportName = 'Report #' . uniqid();
      $reportDefinition->dateRangeType = 'YESTERDAY';
      $reportDefinition->reportType = 'ACCOUNT_PERFORMANCE_REPORT';
      $reportDefinition->downloadFormat = 'XML';

      // Set additional options.
      $options = array('version' => ADWORDS_VERSION);

      // Download report.
      
      $filePath = dirname(dirname(dirname(dirname(__FILE__)))).'/reports/ACCOUNT_PERFORMANCE_REPORT.xml';

      $reportUtils = new ReportUtils();
      $reportUtils->DownloadReport($reportDefinition, $filePath, $user, $options);

In response comes
<?xml version="1.0" encoding="UTF-8"?>
<report>
  <report-name name="Report #57eb948c27c27" />
  <date-range date="Sep 27, 2016" />
  <table>
    <columns>
      <column name="cost" display="Cost" />
      <column name="account" display="Account" />
      <column name="timeZone" display="Time zone" />
    </columns>
  </table>
</report>

And everything is done to get the balance on the account balance
Help, how to correctly formulate a request to the API?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question