I'm using the TargetingIdeaService to get keyword suggestions for a given 
web page. I'm not really interested in the match type, just the keyword 
texts.
With v201109, I would filter on match type BROAD, and request CRITERION 
attributes (I'm using the Java client library v8.7.0):

        TargetingIdeaSelector selector = new TargetingIdeaSelector();
        selector.setRequestType(RequestType.IDEAS);
        selector.setIdeaType(IdeaType.KEYWORD);
        selector.setSearchParameters(new SearchParameter[]{
                new RelatedToUrlSearchParameter(null, new String[]{url}, 
false),
                new KeywordMatchTypeSearchParameter(null, new 
KeywordMatchType[]{KeywordMatchType.BROAD}),
                new LanguageSearchParameter(null, new Language[]{new 
Language(languageCriteria, null, null, null, null)}),
                new LocationSearchParameter(null, new Location[]{new 
Location(countryCriteria, null, null, null, null, null, null)})});
        selector.setRequestedAttributeTypes(new 
AttributeType[]{AttributeType.CRITERION});
        selector.setPaging(new Paging(0, 20));

        TargetingIdeaServiceInterface targetingIdeaService = 
adWordsServiceFactory.createTargetingIdeaService();
        TargetingIdeaPage page = targetingIdeaService.get(selector);
        List<String> keywords = new LinkedList<>();
        if (page.getEntries() != null) {
            for (TargetingIdea idea : page.getEntries()) {
                CriterionAttribute value = (CriterionAttribute) 
idea.getData()[0].getValue();
                Keyword keyword = (Keyword) value.getValue();
                keywords.add(keyword.getText());
            }
        }
        return keywords;

With v201206, I can no longer filter on match type, and I have to request 
attribute KEYWORD_TEXT instead of CRITERION. This would be fine for my use 
case. However, I seem to be getting three of each keyword text. I assume 
this is one for each match type (BROAD, EXACT, PHRASE). However, it doesn't 
make much sense since I can't get information about the match type. In my 
case, since I'm just interested in getting 20 keyword suggestions; I have 
solved it by requesting 3 times as many results and then filtering out the 
duplicates:

        TargetingIdeaSelector selector = new TargetingIdeaSelector();
        selector.setRequestType(RequestType.IDEAS);
        selector.setIdeaType(IdeaType.KEYWORD);
        selector.setSearchParameters(new SearchParameter[]{
                new RelatedToUrlSearchParameter(null, new String[]{url}, 
false),
                new LanguageSearchParameter(null, new Language[]{new 
Language(languageCriteria, null, null, null, null)}),
                new LocationSearchParameter(null, new Location[]{new 
Location(countryCriteria, null, null, null, null, null, null)})});
        selector.setRequestedAttributeTypes(new 
AttributeType[]{AttributeType.KEYWORD_TEXT});
        selector.setPaging(new Paging(0, 60));

        TargetingIdeaServiceInterface targetingIdeaService = 
adWordsServiceFactory.createTargetingIdeaService();
        TargetingIdeaPage page = targetingIdeaService.get(selector);
        Set<String> keywords = new LinkedHashSet<>();
        if (page.getEntries() != null) {
            for (TargetingIdea idea : page.getEntries()) {
                StringAttribute attribute = (StringAttribute) 
idea.getData()[0].getValue();
                keywords.add(attribute.getValue());
            }
        }
        return keywords;

I this a bug in v201206, or am I missing something?

-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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