Hello, I'm trying to send a simple post request to the api to download a report.
And getting a 411 error message which says "POST requests require a content-length header. That's all we know." I'm using the example in here. https://code.google.com/p/google-api-adwords-php/wiki/NoClientLibrary Also tried the new api url https://adwords.google.com/api/adwords/cm/v201309 Has anybody ever come across with this? Any ideas? Thanks! <?php // Provide header information. $authToken = 'INSERT_AUTH_TOKEN_HERE'; $clientCustomerId = 'INSERT_CLIENT_CUSTOMER_ID_HERE'; $developerToken = 'INSERT_DEVELOPER_TOKEN_HERE'; // Create report definition XML. $reportDefinition = <<<EOT <reportDefinition xmlns="https://adwords.google.com/api/adwords/cm/v201109"> <selector> <fields>CampaignId</fields> <fields>Id</fields> <fields>Impressions</fields> <fields>Clicks</fields> <fields>Cost</fields> <predicates> <field>Status</field> <operator>IN</operator> <values>ENABLED</values> <values>PAUSED</values> </predicates> </selector> <reportName>Custom Adgroup Performance Report</reportName> <reportType>ADGROUP_PERFORMANCE_REPORT</reportType> <dateRangeType>LAST_7_DAYS</dateRangeType> <downloadFormat>CSV</downloadFormat> </reportDefinition> EOT; // Create parameters. $params = array('__rdxml' => $reportDefinition); // Create headers. $headers = array(); $headers[]= 'Authorization: GoogleLogin auth=' . $authToken; $headers[]= 'clientCustomerId: ' . $clientCustomerId; $headers[]= 'developerToken: ' . $developerToken; $headers[]= 'content_length: ' . trim(strlen(print_r($params, true))); $headers[]= 'Content-Type: application/x-www-form-urlencoded'; $downloadPath = 'report.csv'; $url = 'https://adwords.google.com/api/adwords/reportdownload/v201109'; $file = fopen($downloadPath, 'w'); $ch = curl_init($url); curl_setopt($ch, CURLOPT_FILE, $file); curl_setopt($ch, CURLOPT_POSTFIELDS, $params); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_exec($ch); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); fclose($file); if ($code == 200) { printf("Report downloaded to: %s\n", $downloadPath); } else { $file = fopen($downloadPath, 'r'); $error = fread($file, 1024); fclose($file); printf("Error: %s\n", $error); } -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ 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 [email protected] To unsubscribe from this group, send email to [email protected] 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 [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
