I have a group of related key phrases, I am looking to get more
related key phrases.  From what I have read, we should be able to
prevent our searched phrases from appearing in the the results by
using the IdeaTextMatchesSearchParameter.excluded parameter, however,
this does not appear to be working correctly.  Hopefully someone can
explain why my results still contains the phrases I am searching for.
Here is my PHP code below:

//create the user
$user = new AdWordsUser();
//create the array of phrases
$array_random_phrases = array("chocolate gifts", "chocolate gift
baskets", "chocolate baskets", "chocolate gift ideas");
// Get the TargetingIdeaService.
$targetingIdeaService = $user->GetTargetingIdeaService('v201008');
//go through the array
foreach($array_random_phrases as $text){
        // Create seed keyword.
        $keyword = new Keyword();
        $keyword->text = $text;
        $keyword->matchType = 'PHRASE';
        $array_key_word_objects[] = $keyword;
}//foreach
// Create selector.
$selector = new TargetingIdeaSelector();
$selector->requestType = 'IDEAS';
$selector->ideaType = 'KEYWORD';
$selector->requestedAttributeTypes = array('KEYWORD');
// Set selector paging (required for targeting idea service).
$paging = new Paging();
$paging->startIndex = 0;
$paging->numberResults = 20;
$selector->paging = $paging;
// Create related to keyword search parameter.
$relatedToKeywordSearchParameter = new
RelatedToKeywordSearchParameter();
$relatedToKeywordSearchParameter->keywords = $array_key_word_objects;
$selector->searchParameters[] = $relatedToKeywordSearchParameter;
// Create keyword match type search parameter to ensure unique
results.
$keywordMatchTypeSearchParameter = new
KeywordMatchTypeSearchParameter();
$keywordMatchTypeSearchParameter->keywordMatchTypes = array('PHRASE');
$selector->searchParameters[] = $keywordMatchTypeSearchParameter;
//exclude the searched parameters from the results
$ideaTextMatchesSearchParameter = new
IdeaTextMatchesSearchParameter();
$ideaTextMatchesSearchParameter->excluded = $array_random_phrases;
$selector->searchParameters[] = $ideaTextMatchesSearchParameter;
// Get related keywords.
$page = $targetingIdeaService->get($selector);
// Display related keywords.
if (isset($page->entries)) {
        //go through the array
        foreach ($page->entries as $targetingIdea) {
                $data = MapUtils::GetMap($targetingIdea->data);
                $keyword = $data['KEYWORD']->value;
                $array_results[] = $keyword->text;

        }//foreach
        print("Searching for : <br />" );
        print_r($array_random_phrases);
        print("<br /><br />Results :<br />" );
        print_r($array_results);
}//if
else {
        print "No related keywords were found.\n";
}//else

-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
http://adwordsapi.blogspot.com
http://groups.google.com/group/adwords-api
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en

Reply via email to