Hi,

I try to get keyword performance report by fallowing this specification:
https://developers.google.com/adwords/api/docs/guides/reporting?hl=lt.

Everything works fine, except that result are different by comparing with 
results directly from MCC.
Totals of fallowing field:
clicks, cost
are different than from MCC form the same client and same data range.
Result from MCC is slightly larger than result from http request using 
AdHoc method.

Why? 
Maybe someone you have suggestions on what to pay attention, or what might be 
wrong ?

My code looks like:
// Account login details
    $username = "xxx";
    $password = "xxx";
    $customerId = "xxx";  
    $devToken = "xxx";
     
    // Get an access code for the user
    $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);
     
    // Parse the response
    $curlData = explode("\n", $curlData);
    $return = array();
    foreach ($curlData as $value) {
        $value = explode("=", $value, 2);
        if (count($value) > 1) {
            $return[$value[0]] = $value[1];
        }
    }
    // Extract the access token
    $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 .= "<dateRangeType>CUSTOM_DATE</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