Hi,

I try to get keywords performance report by using HTTP REQUEST 
(https://developers.google.com/adwords/api/docs/guides/reporting?hl=lt#adhoc).

Everything works fine, no error appears. But line of "Total" are different 
comparing data with from MCC. Currently "total cost" and click count are 
different. "Avg. CPC" is ok.

Whats wrong? I try to get report for LAST_MONTH.

Each time, when i try to get report data, "total" are less than from MCC.

Maybe someone have suggestions?

My script is:


    $username = "xxx";
    $password = "xxx";
    $customerId = "26161561651561561"; 
    $devToken = "dasfws46aer546r5g1er6a51";
     
    $url = "https://www.google.com/accounts/ClientLogin";;
    $params = array(
        "accountType" => "GOOGLE",
        "Email" => $username,
        "Passwd" => $password,
        "service" => "adwords",
        "source" => "test"
    );
     
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_HEADER, false);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
    //curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    $curlData = curl_exec($curl);
    curl_close($curl);
     
    $curlData = explode("\n", $curlData);
    $return = array();
    foreach ($curlData as $value) {
        $value = explode("=", $value, 2);
        if (count($value) > 1) {
            $return[$value[0]] = $value[1];
        }
    }

    $authToken = $return["Auth"];
    
    #
    $httpHeaders = array(
        "Authorization: GoogleLogin auth=$authToken",
        "clientCustomerId: $customerId",
        "developerToken: $devToken"
    );
    
    #
    $reportDefinition = "<reportDefinition>"; 
    $reportDefinition .= "<selector>";
    $reportDefinition .= "<fields>Id</fields>";
    $reportDefinition .= "<fields>Date</fields>";
    $reportDefinition .= "<fields>ExternalCustomerId</fields>";
    $reportDefinition .= "<fields>AccountDescriptiveName</fields>";
    $reportDefinition .= "<fields>CampaignId</fields>";
    $reportDefinition .= "<fields>Clicks</fields>";
    $reportDefinition .= "<fields>AverageCpc</fields>";
    $reportDefinition .= "<fields>Cost</fields>";
    $reportDefinition .= "</selector>";
    $reportDefinition .= "<reportName>Keywords Performance 
Report</reportName>";
    $reportDefinition .= 
"<reportType>KEYWORDS_PERFORMANCE_REPORT</reportType>";
    $reportDefinition .= "<dateRangeType>LAST_MONTH</dateRangeType>";
    $reportDefinition .= "<downloadFormat>CSV</downloadFormat>";
    $reportDefinition .= 
"<includeZeroImpressions>true</includeZeroImpressions>";
    $reportDefinition .= "</reportDefinition>";
     
    $params = array("__rdxml" => $reportDefinition);
    
    
    #
    $url = "https://adwords.google.com/api/adwords/reportdownload/v201109";;
 
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_HEADER, false);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
    curl_setopt($curl, CURLOPT_HTTPHEADER, $httpHeaders);
    //curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    $reportData = curl_exec($curl);
    curl_close($curl);
     
    print "$reportData\n";


-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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