Josh is right, you can do it this way also: 

$query = "SELECT Clicks, Impressions, Cost FROM ACCOUNT_PERFORMANCE_REPORT 
DURING 20140101,20140131"; 
$options = array('version' => ADWORDS_VERSION);

$response = 
ReportUtils::DownloadReportWithAwql($query,NULL,$user,"XML",$options);
$xml = new SimpleXMLElement($response);
// after we have our XML object, declare where the rows are:
$rows = $xml->xpath('/report/table/row');

// now loop through them and do things: 
foreach($rows as $row) { 
   $clicks      = $row->attributes()->clicks;
   $impressions = $row->attributes()->impressions;
   $cost        = $row->attributes()->cost;
   // or just var_dump to show all the data, raw:
   var_dump($row);
} 


On Friday, March 14, 2014 9:39:31 AM UTC-5, Jake Wilson wrote:
>
> Ah excellent.  I will look into that approach.  Thanks!
>
> Jake
>
> On Friday, March 14, 2014 8:02:41 AM UTC-6, Josh Radcliff (AdWords API 
> Team) wrote:
>>
>> Hi,
>>
>> Although the example shows how to download to a file, you can download a 
>> report and just process it in memory.  Simply pass NULL for the second 
>> argument to *DownloadReportWithAwql* (or *DownloadReport*).
>>
>>    $adwords_config = array(
>>             'server'    => 'https://adwords.google.com',
>>             'version'   => 'v201402',
>>
>>    );
>>    $response = ReportUtils::DownloadReportWithAwql(
>>        $query, NULL, $user, self::FORMAT_XML, $adwords_config);
>>  
>>    return simplexml_load_string($response);
>>
>> The API also allows you to specify different formats for your report, 
>> e.g., XML as in the example above. It sounds like this would be preferable 
>> for your use case.
>>
>> Cheers,
>> Josh, AdWords API Team
>>
>> On Friday, March 14, 2014 12:43:24 AM UTC-4, Jake Wilson wrote:
>>>
>>> Using the PHP Lib, there is the ReportUtils.php class(es).  The way the 
>>> example scripts work for reporting is that your report is downloaded to a 
>>> file on your computer.  The file is pre-formatted sort of like this:
>>>
>>> Report Title Blah Blah StartDate - End Date
>>> CSV column description
>>> data rows (csv style)
>>> data rows (csv style)
>>> data rows (csv style)
>>> data rows (csv style)
>>> Totals --- --- --- -- 
>>>
>>> I've been glancing through the code and there isn't any sort of option 
>>> to just download the data directly as an array or json or whatever.  Why is 
>>> this?  Every other aspect of the library fetches data directly to variables 
>>> and class structures.  Why do the reports require you to download a file to 
>>> your filesystem that you need to turn around and parse?  Looking at the 
>>> above file, I just want the data.  I don't want the Title line or columns 
>>> descriptions or totals at the bottom.  I just want the data.
>>>
>>> Right now I am simply downloading the file, then reading it in and 
>>> parsing it and then deleting the file.  But it would be nice if downloading 
>>> this data was more consistent with the rest of the PHP Lib.
>>>
>>> Any thoughts or explanations on why this is?
>>>
>>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to