Forum Moderators: martinibuster
<?php
$username='me.test@gmail.com';
$password="........";
$daterange = 20 ;
$cookie="./tmp/.cookiefile";
$daysbefore = mktime(0, 0, 0, date("m") , date("d") - $daterange, date("Y"));
list ($d_from,$m_from,$y_from) = split(':',date("j:n:Y", $daysbefore));
list ($d_to,$m_to,$y_to) = split(':',date("j:n:Y"));
$destination="/adsense/report/aggregate?"
."sortColumn=0"
."&reverseSort=false"
."&outputFormat=TSV_EXCEL"
."&product=afc"
."&dateRange.simpleDate=today"
."&dateRange.dateRangeType=custom"
."&dateRange.customDate.start.day=$d_from"
."&dateRange.customDate.start.month=$m_from"
."&dateRange.customDate.start.year=$y_from"
."&dateRange.customDate.end.day=$d_to"
."&dateRange.customDate.end.month=$m_to"
."&dateRange.customDate.end.year=$y_to"
."&unitPref=page"
."&reportType=property"
."&searchField="
."&groupByPref=date";
$postdata="destination=".urlencode($destination)."&username=".urlencode($username)."&password=".urlencode($password)."&null=Login";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL,"https://www.google.com/adsense/login.do");
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt ($ch, CURLOPT_TIMEOUT, 20);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt ($ch, CURLOPT_COOKIEFILE, $cookie);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt ($ch, CURLOPT_POST, 1);
$result = curl_exec ($ch);
curl_close($ch);
echo $result;
?>
After running this code, I see google adsense login page with this text in form : Invalid email address or password
I guess problem is from a dot in email address (like me.test@gmail.com). has anyone a solution for this big problem?
$HCurl=curl_init();
curl_setopt($HCurl,CURLOPT_POST,1);
curl_setopt($HCurl,CURLOPT_POSTFIELDS,"username=".$AUsername."&password=".$APassword);
curl_setopt($HCurl,CURLOPT_URL,"https://www.google.com/adsense/login.do");
curl_setopt($HCurl,CURLOPT_SSL_VERIFYHOST,2);
curl_setopt($HCurl,CURLOPT_RETURNTRANSFER,1);
curl_setopt($HCurl,CURLOPT_USERAGENT,$user_agent);
curl_setopt($HCurl,CURLOPT_SSL_VERIFYPEER,FALSE);
curl_setopt($HCurl,CURLOPT_FOLLOWLOCATION,TRUE);
curl_setopt($HCurl,CURLOPT_COOKIEFILE,$cookie);
$data=curl_exec($HCurl);
$AUsername and $APassword are not urlencoded.