November 9, 2008 by Alex Polski

PHP account adsense monitor

There is a nice PHP class for the retrieving the data from Google Adsense account like impressions, clicks, ctr, ecpm and earnings – PHP account adsense monitor. But it does not work now, seems Google updated the authorization system for Adsense. I’ve fixed it a bit and now you can use it in your web applications.

A small example:

<?php
include('adsense.php');

$adsense = new AdSense();
if ($adsense->connect('username', 'password'))
{
  $data = $adsense->yesterday();
  var_dump($data);
}
else
{
  die('Could not login to AdSense account!');
}
?>

This code will output something like this:

array(5) {
  ["impressions"]=>
  string(2) "49"
  ["clicks"]=>
  string(1) "0"
  ["ctr"]=>
  string(5) "0.00%"
  ["ecpm"]=>
  string(5) "$0.00"
  ["earnings"]=>
  string(5) "$0.00"
}

You can download the script here.

Share and Enjoy:
  • Sphinn
  • del.icio.us
  • Digg
  • Reddit
  • Slashdot
  • Technorati
  • Propeller
  • Facebook
  • StumbleUpon
  • LinkedIn
  • blogmarks
  • Google Bookmarks
  • Live
  • MisterWong
  • MySpace
  • Netvibes
  • Yahoo! Buzz
  • Twitter
  • Yahoo! Bookmarks
  • Identi.ca
  • E-mail this story to a friend!
This entry was posted on Sunday, November 9, 2008 at 2:04 pm and is filed under Adsense. Both comments and pings are currently closed.

Related posts

« How to develop a good scraper on Perl – Lesson 3

Scrapy framework »



3 Responses to “PHP account adsense monitor”

BorisK
Posted on December 5th, 2008 at 3:46 pm

It should be:
if (connect(’username’, ‘password’))

instead of:
connect(’username’, ‘password’))

Alex Polski
Posted on December 6th, 2008 at 1:32 pm

Ahh, thanks a lot BorisK!

Mike
Posted on March 8th, 2009 at 6:57 am

It doesn’t seem to work anymore – is this something deliberate by Google to stop people accessing their AdSense data, or genuine updates? It would be nice of Google to provide an access or API for this instead.