PHP AdSense Account Library

Based on PHP AdSense account monitor class

PHP AdSense Account Library is a class that can retrieve various data from an AdSense account.

Examples

require_once('adsense.php');

$username = 'rogerio.albandes@gmail.com';
$password = '';

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

API

connect($username, $password)

Connects to AdSense account using supplied credentials. Returns true on unsuccessful connection, false otherwise.

log_out()

Log out from adsense. Useful when getting data from two or more accounts.

today()

Gets AdSense data for the period: today. Returns associative array with collected data

yesterday()

Gets AdSense data for the period: yesterday. Returns associative array with collected data

last7days()

Gets AdSense data for the period: last7days. Returns associative array with collected data

lastmonth()

Gets AdSense data for the period: lastmonth. Returns associative array with collected data

thismonth()

Gets AdSense data for the period: thismonth. Returns associative array with collected data

sincelastpayment()

Gets AdSense data for the period: sincelastpayment. Returns associative array with collected data

get_report_id_from_name($name)

Get current report id by report name. Helps to avoid problems with report editing and ids.

get_report_as_csv($report_id, $encoding = 'UTF-8')

Get csv data from custom report.

Warning: if you will edit report at Google Adsense page, its id will change!

report($report_id)

Get report data as array. Uses html parser. A bit slower than get_report_as_csv().

Warning: if you will edit report at Google Adsense page, its id will change!

quick_report($url)

© 2009, Alex Polski, Alexander Makarov