Forum Moderators: martinibuster

Message Too Old, No Replies

AdSense remote login problem

adsense, php, curl

         

reza56

12:15 am on Oct 8, 2006 (gmt 0)

10+ Year Member



Hi,
I want to use this script for my site [webmasterworld.com...]
but it don't works. I change it to finding problem :


<?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?

elfred

8:10 am on Oct 8, 2006 (gmt 0)

10+ Year Member



This works fine for me:

$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.

reza56

10:26 pm on Oct 8, 2006 (gmt 0)

10+ Year Member



I test your code. it is not working as same as my code. is your email has two dots like my email (for example : me.test@gmail.com)?

elfred

6:20 pm on Oct 9, 2006 (gmt 0)

10+ Year Member



No, it hasn't, but I don't think it would make any difference.

reza56

9:04 pm on Oct 9, 2006 (gmt 0)

10+ Year Member



I test this code with another account and that works very well. the only think I guess is this dor between username of email account like me.test in me.test@gmail.com? I am so sad about this problem.

reza56

10:09 am on Oct 11, 2006 (gmt 0)

10+ Year Member



has anyone any idea?

ashii

4:01 pm on Oct 11, 2006 (gmt 0)

10+ Year Member



Why this script is used?

reza56

10:21 pm on Oct 11, 2006 (gmt 0)

10+ Year Member



I combine this code with some programs that generate some calculated reports about earnings and ... . I used it in another account but I change my account because changing country. changing email is very defficult in adsense when using a google account.