define('CLIENT_ID', 'MY_CLIENT_ID');
define('CLIENT_SECRET', 'MY_CLIENT_SECRET');
define('REFRESH_TOKEN', 'MY_REFRESH_TOKEN');
define('DEVELOPER_TOKEN', 'MY_DEVELOPER_TOKEN');
define('USER_AGENT', 'MY_COMPANY');
$oauth2Info = array(
'client_id' => CLIENT_ID,
'client_secret' => CLIENT_SECRET,
'refresh_token' => REFRESH_TOKEN
);
$user = new AdWordsUser(null, DEVELOPER_TOKEN, USER_AGENT, null, null,$oauth2Info);
$user->SetClientCustomerId('MY_ID');//this is my sub client-customer id
// Log every SOAP XML request and response.
$user->LogAll();
$user->LoadService('ReportDefinitionService', ADWORDS_VERSION);
$selector = new Selector();
$selector->fields = array('AccountCurrencyCode', 'AccountDescriptiveName', 'AccountTimeZoneId', 'ActiveViewCpm',
'ActiveViewCtr', 'ActiveViewImpressions', 'ActiveViewMeasurability', 'ActiveViewMeasurableCost');
$reportDefinition = new ReportDefinition();
$reportDefinition->selector = $selector;
$reportDefinition->reportName = 'Criteria performance report #' . uniqid();
$reportDefinition->dateRangeType = 'LAST_7_DAYS';
$reportDefinition->reportType = 'CAMPAIGN_PERFORMANCE_REPORT';
$reportDefinition->downloadFormat = 'CSV';
$options = array('version' => ADWORDS_VERSION);
$reportUtils = new ReportUtils();
$reportUtils->DownloadReport($reportDefinition, "report.csv", $user, $options);