Hello!

I'm trying to see if I can work outside the PHP client library while waiting 
on it to be updated to support the new AdHoc reporting methods. From what I 
can guess, either my cURL request is bogus, my headers are incorrect, or the 
token I'm trying to use (created through OAuth) is not letting me in.

Expected Result:
    An XML document containing report data.

Getting:
    !!!2|||-1|||AuthenticationError.GOOGLE_ACCOUNT_COOKIE_INVALID @ 
Service[ReportInfoService.get]???

My code:
---

<?php

/* Replace with legitimate credentials */
$authToken = '1/7xrnwyLT...uN4iAXRk';
$clientCustomerId = '1234567890';

/* Report Definition */
$xml = '<reportDefinition>
  <selector>
    <fields>Date</fields>
    <fields>CampaignId</fields>
    <fields>Id</fields>
    <fields>HourOfDay</fields>
    <fields>Impressions</fields>
    <fields>Clicks</fields>
    <fields>Cost</fields>
    <predicates>
      <field>BiddingStrategy</field>
      <operator>IN</operator>
      <values>BidToPosition</values>
      <values>CpaPercent</values>
    </predicates>
    <dateRange>
      <min>20111001</min>
      <max>20111031</max>
    </dateRange>
  </selector>
  <reportName>Test Report</reportName>
  <reportType>ADGROUP_PERFORMANCE_REPORT</reportType>
  <dateRangeType>CUSTOM_DATE</dateRangeType>
  <downloadFormat>CSV</downloadFormat>
</reportDefinition>';

/* Authentication Headers */
$headers = array();
$headers[] = 'Authorization: GoogleLogin auth=' .  $authToken;
$headers[] = 'clientCustomerId: ' . $clientCustomerId;
$headers[] = 'returnMoneyInMicros: true';

/* Report Definition */
$post = array();
$post['__rdxml'] = $xml;

/* cURL Request */
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 
'https://adwords.google.com/api/adwords/reportdownload/v201109');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);

// Get Response
$response = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);


/* Debugging */
print '<pre>Headers:<br />';
print_r($headers);
print '<hr />XML:<br />';
print htmlentities($xml);
print '<hr />';
print 'HTTP Code: ' . $code . '<hr />';
print htmlentities($response);
print '<hr />Errors:<br />';
$errors = array( 'errno' => curl_errno($ch), 'error' => curl_error($ch)) ;
print_r($errors);

-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
http://adwordsapi.blogspot.com
http://groups.google.com/group/adwords-api
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

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

Reply via email to