Auto logging into AdSense

Discussion in 'AdSense' started by fortytwo, Apr 24, 2006.

  1. #1
    I've found these old posts from 2003 about how to automatically log in to AdSense, and get right to the page you are looking at. I guess Google changed their login code to keep so many people from doing insecure GETs to log in, because it doesn't work anymore.

    Here is what people used to say:

    Just type the following into your browser:
    https://www.google.com/adsense/login.do?username=USER&password=PASS

    This doesn't work anymore. The login.do page I think is still the same, but their form variables show the username form to now be called "Email" and the password form is called "Passwd". However, substituting those into the URL doesn't work either.

    I'm not planning on logging in using GETs. I'm actually trying to write something so I can set an hourly job to log into my adsense account (using POSTs with Net::HTTP in ruby), and then dumping my stats into a database.

    Does anyone know how I can do this these days?

    Thanks,
    -Fortytwo
     
    fortytwo, Apr 24, 2006 IP
  2. seolion

    seolion Active Member

    Messages:
    1,495
    Likes Received:
    97
    Best Answers:
    0
    Trophy Points:
    90
    #2
    Why dont you try a firefox addon which displays the adsense earnings. On a click on this adsense ticker, you get logged in automatically.
     
    seolion, Apr 24, 2006 IP
  3. mark1

    mark1 Peon

    Messages:
    372
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
  4. tonyinabox

    tonyinabox Peon

    Messages:
    1,988
    Likes Received:
    42
    Best Answers:
    0
    Trophy Points:
    0
    #4
    or try google desktop adsense stats as well.
     
    tonyinabox, Apr 25, 2006 IP
  5. jimkarter

    jimkarter Notable Member

    Messages:
    5,168
    Likes Received:
    347
    Best Answers:
    0
    Trophy Points:
    235
    #5
    this firefox pluging works great. I am using it and i m in love with it.
     
    jimkarter, Apr 25, 2006 IP
  6. broke-r

    broke-r Peon

    Messages:
    98
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    WOW Never heard of the Firefox plugin before.... Thanks!
     
    broke-r, Apr 25, 2006 IP
  7. fortytwo

    fortytwo Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Yeah, I use that plugin too, but thats not really why I need to do this. I'm trying to auto-import my stats so I can programmatically aggregate the stats and see them different ways.

    Anyway, I found some code snippets... The code is in PHP, and I found it here:
    http://www.webmasterworld.com/forum89/5349.htm

    The two snippets listed in that thread are a little out of date, but it should be pretty easy to port to whatever language. It looks like what I was really missing was some sort of cookie handling. I guess Google boots you back out if you don't accept and retain their cookie or something.

    The scripts they feature in the forum post listed above are for setting up a cron job to automatically SMS or email you periodically with your AdSense stats. Here is a very slightly modified version of the script that worked for me...

    <?
    $username="uername@email.com";
    $password="pass";
    $cookie="/mywebsite.com/adsense/cookiefile";
    $log="/mywebsite.com/adsense/adsense.log.txt";
    $destination="/adsense/report/aggregate";
    
    $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);
    
    preg_match('/\<tr class\="totals"\>.*\<td.*\>.*\<\/td\>.*\<td.*\>(.*)\<\/td\>.*\<td.*\>(.*)\<\/td\>.*\<td.*\>(.*)\<\/td\>.*\<td.*\>(.*)\<\/td\>.*\<td.*\>(.*)\<\/td\>.*<\/tr>/simU', $result, $array);
    foreach ($array as $key => $value) {$array[$key] = trim($value, "\x22\x27\n\r ");} // strip $ % , here if desired
    list($full,$Impressions,$Clicks,$Rate,$CPM,$Earnings) = $array;
    
    putenv('TZ=US/Pacific'); // match Google time no matter where you or your serverlive
    $output=date("Y-m-d H:i:s")." \t Impressions: ".$Impressions." \t Clicks: ".$Clicks." \t Rate: ".$Rate." \t CPM: ".$CPM." \t Earnings: ".$Earnings."\r\n";
    if ($handle = fopen($log, 'a')) {fwrite($handle, $output); fclose($handle);} else {echo "error writing";}
    
    //mail("5555555555@mobile.att.net", "Adsense report", $output, "From: Adsense");
    mail("myemail@email.com", "Adsense report", $output, "From: Adsense");
    ?> 
    PHP:
    Hope that helps anyone else out there looking for a solution to this problem.
     
    fortytwo, Apr 25, 2006 IP
  8. tonyinabox

    tonyinabox Peon

    Messages:
    1,988
    Likes Received:
    42
    Best Answers:
    0
    Trophy Points:
    0
    #8
    make sure this not affect your account
     
    tonyinabox, Apr 25, 2006 IP
  9. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #9
    digitalpoint, Apr 25, 2006 IP
  10. projectw3

    projectw3 Banned

    Messages:
    713
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #10
    How did that happen? The site always log me out automatically or times out.

     
    projectw3, Apr 25, 2006 IP
  11. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #11
    Beats me... I didn't do anything special.
     
    digitalpoint, Apr 25, 2006 IP
  12. dotcompals

    dotcompals Prominent Member

    Messages:
    2,905
    Likes Received:
    254
    Best Answers:
    0
    Trophy Points:
    320
    #12
    Best option is to use the FireFox Plugin and then right click on that Plugin icon to auto login to your adsense account.
     
    dotcompals, Apr 26, 2006 IP
  13. Sonu2007

    Sonu2007 Banned

    Messages:
    467
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #13
    this was gr8
    i was tried it
     
    Sonu2007, Apr 26, 2006 IP
  14. SHT

    SHT Active Member

    Messages:
    266
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    73
    #14
    Sysense, also auto logs you in by creating a temporary page which has javascript to auto log you in. Install sysense, right click the icon > open adsense account > click the account. - Auto logs in :)

    Edit: I also read somewhere, google don't mind programmes into your account as long they don't do it more than every 15mins and it doesn't break the TOS in any other way.
     
    SHT, Apr 26, 2006 IP
  15. RatDog

    RatDog Peon

    Messages:
    298
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #15
    A month or so back I asked G about this. They said they don't have a preference for the time interval between checks.
     
    RatDog, Apr 26, 2006 IP