I'd like to get the daily amount spend for a dateRange of a 
day/week/month/year.
This is so I can make a graph of it, and display it in our own system.

I have come to the conclusion that this will be only possible if I get the 
costs for a specific date *30 times*.
$user = new AdWordsUser();
$user->SetClientCustomerId('xxx-xxx-xxxx');
$service = $user->LoadService('ReportDefinitionService', ADWORDS_VERSION);
$options = array('version' => ADWORDS_VERSION);
$allReports = array();

// Get a report 30 times
for ($i=1; $i <= 30; $i++) { 
    // Make the dateRange for that day.
    $dateRange = sprintf('%d,%d', date('Ymd', strtotime('-' . $i . ' day')), 
date('Ymd', strtotime('-' . $i . ' day')));
    $reportQuery = 'SELECT Cost FROM ACCOUNT_PERFORMANCE_REPORT DURING ' . 
$dateRange;

    $reportUtils = new ReportUtils();

    // Note: 2nd argument given is null so DownloadReportWithAwql() does 
not actually download is but returns it.
    $thisDayReport = $reportUtils->DownloadReportWithAwql($reportQuery, null
, $user, 'XML', $options);

    // Put the current report in an array, parsing the returned xml into an 
array.
    array_push($allReports, simplexml_load_string($thisDayReport));
}

// Print the results.
print_r($allReports);

This works, although it takes 30 calls en about 2 minutes to complete, it 
does. 
I was wondering, isn't there any other (easier/quicker) way I could do this?

If I was to use this, I would probably do a cron-job once a week and fill 
my own database with the data that it gets (kinda like indexing) 

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/ed603ad5-0681-43d0-9a2d-4b92e5e86866%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
  • How to get the ... marketing
    • Re: How to... 'Shwetha Vastrad (AdWords API Team)' via AdWords API Forum

Reply via email to