<?php
$path = dirname( __FILE__ ) . PATH_SEPARATOR . "lib";
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'lib/Google/Api/Ads/AdWords/Lib/AdWordsUser.php';
require_once 'lib/Google/Api/Ads/Common/Util/MapUtils.php';
function getWord(AdWordsUser $user) {
// Get the service, which loads the required classes.
$targetingIdeaService = $user->GetTargetingIdeaService('v201402');
// Create seed keyword.
$keyword = 'Books';
// Create selector.
$selector = new TargetingIdeaSelector();
$selector->requestType = 'IDEAS';
//$selector->requestType = 'STATS';
$selector->ideaType = 'KEYWORD';
$selector->requestedAttributeTypes =
array('AVERAGE_CPC', 'COMPETITION', 'SEARCH_VOLUME', 'TARGETED_MONTHLY_SEARCHES');
// Create related to keyword search parameter.
$selector->searchParameters[] =
new RelatedToQuerySearchParameter(array($keyword));
// Set selector paging (required by this service).
$selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
do {
// Make the get request.
$page = $targetingIdeaService->get($selector);
// Display results.
if (isset($page->entries)) {
print_r ( $page->entries );
} else {
print "N/A";
}
// Advance the paging index.
$selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
} while ($page->totalNumEntries > $selector->paging->startIndex);
}
try {
$oauth2Info = array(
'client_id' => "my_client_id",
'client_secret' => "my_client_secret",
'refresh_token' => 'my_refresh_token'
);
$user = new AdWordsUser(NULL, 'my_email', 'my_password', 'my_email++currency', 'my_token', 'user_agent', NULL, NULL, NULL, $oauth2Info);
$user->SetClientId('xxx-xxx-xxxx');
// Run the example.
getWord($user);
} catch (Exception $e) {
printf($e->getMessage());
}
?>