<?php

// Adwords Namespace
define('CONF_ADWORDS_NAMESPACE', 'https://adwords.google.com/api/adwords/v2');

// Google InfoService URI
define('WSDL_URI_INFOSERVICE',
       'https://adwords.google.com/api/adwords/v2/InfoService?wsdl');

// Google Adwords' account information
define('CONF_ADWORDS_EMAIL',    'my.email.address@example.com');
define('CONF_ADWORDS_PASSWORD', 'my-password');
define('CONF_ADWORDS_TOKEN',    'my-token');

// User agent to report back to google
define('CONF_ADWORDS_AGENT', 'PHP script');


$soap_headers = array(
    new SoapHeader(CONF_ADWORDS_NAMESPACE, 'email', CONF_ADWORDS_EMAIL),
    new SoapHeader(CONF_ADWORDS_NAMESPACE, 'password', CONF_ADWORDS_PASSWORD),
    new SoapHeader(CONF_ADWORDS_NAMESPACE, 'useragent', CONF_ADWORDS_AGENT),
    new SoapHeader(CONF_ADWORDS_NAMESPACE, 'token', CONF_ADWORDS_TOKEN));


try {
    $info_client = new SoapClient(WSDL_URI_INFOSERVICE);
} catch (Exception $e) {
    echo "Unable to create SOAP client: {$e->faultstring}\n";
    exit(1);
}

try {
    $res = $info_client->__soapCall('getOperationsQuotaThisMonth',
                                    array('parameters' => array()),
                                    NULL, $soap_headers);
} catch (Exception $e) {
    echo "The SOAP method call failed: {$e->faultstring} ({$e->faultcode})\n";
    exit(1);
}

echo "Quota for this month: {$res->getOperationsQuotaThisMonthReturn}\n";

?>