Hi Eric,
Here is code I'm using, its very basic.
####################Code######################
<?php
error_reporting(E_STRICT | E_ALL);
date_default_timezone_set("Europe/Brussels");
$path = dirname(__FILE__) . '/../../src';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'Google/Api/Ads/AdWords/Lib/AdWordsUser.php';
class GetAllKeywordsExample {
static function main($keywords_input, $match_type) {
$return_array = array();
try {
// Get AdWordsUser from credentials in "../auth.ini"
// relative to the AdWordsUser.php file's directory.
$user = new AdWordsUser();
// Log SOAP XML request and response.
$user->LogDefaults();
$keywordService = $user->GetTargetingIdeaService();
$keyword = new Keyword();
$keyword->text = $keywords_input;
$keyword->matchType = $match_type;
$languageService= new LanguageTarget();
$languageService->languageCode='en';
$languageService->TargetType='en';
$countryService= new CountryTargetSearchParameter();
$countryService->countryTargets='UK';
$keyword_array = array($keyword);
$relatedToKeywordSearchParameter = new
RelatedToKeywordSearchParameter($keyword_array, $languageService,
$countryService);
$targetingIdeaSelector = new TargetingIdeaSelector();
$targetingIdeaSelector->searchParameters = array(
$relatedToKeywordSearchParameter
);
$targetingIdeaSelector->ideaType = 'KEYWORD';
$targetingIdeaSelector->requestType = 'IDEAS';
$targetingIdeaSelector->requestedAttributeTypes=array
( 'KEYWORD','GLOBAL_MONTHLY_SEARCHES',
'KEYWORD_CATEGORY','COMPETITION' );
$targetingIdeaSelector->paging = new Paging(0,400);
$keywordPage = $keywordService->get($targetingIdeaSelector);
$return_array=array();
if(isset($keywordPage->entries)) {
foreach ($keywordPage->entries as $keyword_entry) {
foreach($keyword_entry as $keyword_entry_array){
foreach ($keyword_entry_array as $keyword){
if($keyword->key == 'KEYWORD'){
$keyword_value = $keyword->value;
$kwtext=$keyword_value->value->text;
}
if($keyword->key == 'GLOBAL_MONTHLY_SEARCHES'){
$keyword_value = $keyword->value;
$gms=$keyword_value->value;
}
if($keyword->key == 'KEYWORD_CATEGORY'){
$keyword_value = $keyword->value;
$kwcat=$b = implode (',', $keyword_value->value);
}
$return_array[] = array( $kwtext, $gms, $kwcat);
}
}
}
} else {
throw new Exception("No keyword found",0);
}
} catch (Exception $e) {
$return_array[] = array(
'keyword'=>$e->getMessage());
}
return $return_array;
}
}
$result = GetAllKeywordsExample::main("computer", 'BROAD');
var_dump($result);
?>
##################Output###############
I get an array with with three elemnts.
Keyword, Monthly Searches and Keyword Category code.
However, Keyword category is mostly null for many ovbious terms (You
can try with terms like computer, kfc etc.). Also, where do we get
the category name and code mapping table to map the category id to a
category name.
Hope this helps.
Thanks...........Shiv
On Nov 10, 9:52 pm, AdWords API Advisor <
adwordsapiadvi...@google.com>
wrote: