Hi,

By default the TargetingIdeaService will return results with any match
type, so your results could include:

  john/BROAD
  john/PHRASE
  john/EXACT

Using the keyword text as the key in your dictionary is not
sufficient, since the same keyword text can be returned with different
match types.  You can limit the match types of the results by using
the KeywordMatchTypeSearchParameter:

  
http://code.google.com/apis/adwords/v2009/docs/reference/TargetingIdeaService.KeywordMatchTypeSearchParameter.html

Best,
- Eric Koleda, AdWords API Team

On Jul 7, 3:24 pm, parviz <[email protected]> wrote:
> I tried almost everything but this thing doesnt work! I keep getting
> An item with the same key has already been added.
>
>             AdWordsUser user = new AdWordsUser();
>             TargetingIdeaService targetingIdeaService =
> (TargetingIdeaService)user.GetService(AdWordsService.v201003.TargetingIdeaS 
> ervice);
>
>             TargetingIdeaSelector selector = new
> TargetingIdeaSelector();
>
>             CountryTargetSearchParameter countryTargetSearchParam =
> new CountryTargetSearchParameter();
>             CountryTarget target1 = new CountryTarget();
>             target1.countryCode = "US";
>             countryTargetSearchParam.countryTargets = new
> CountryTarget[] { target1 };
>
>             RelatedToKeywordSearchParameter
> relatedToKeywordSearchParam = new RelatedToKeywordSearchParameter();
>
>             Keyword keyword = new Keyword();
>             keyword.text = "john";
>             keyword.matchTypeSpecified = true;
>             keyword.matchType = KeywordMatchType.BROAD;
>
>             relatedToKeywordSearchParam.keywords = new Keyword[]
> { keyword };
>
>             selector.searchParameters = new SearchParameter[]
> { countryTargetSearchParam, relatedToKeywordSearchParam };
>
>             selector.ideaTypeSpecified = true;
>             selector.ideaType = IdeaType.KEYWORD;
>
>             selector.requestTypeSpecified = true;
>             selector.requestType = RequestType.IDEAS;
>
>             selector.paging = new Paging();
>             selector.paging.startIndexSpecified = true;
>             selector.paging.startIndex = 0;
>             selector.paging.numberResultsSpecified = true;
>             selector.paging.numberResults = 10;
>             selector.requestedAttributeTypes = new AttributeType[]
>             {
>                  AttributeType.KEYWORD,
>                  AttributeType.AVERAGE_TARGETED_MONTHLY_SEARCHES,
>
>            };
>
>             TargetingIdeaPage page =
> targetingIdeaService.get(selector);
>             Dictionary<string, double> dict = new Dictionary<string,
> double>();
>
>             string keyword1 = "";
>             double monthlySearches = 0;
>             foreach (TargetingIdea idea in page.entries)
>             {
>
>                 foreach (Type_AttributeMapEntry entry in idea.data)
>                 {
>
>                     string ss = entry.key.ToString();
>                     switch (entry.key)
>                     {
>                         case AttributeType.KEYWORD:
>                             keyword1 =
> ((KeywordAttribute)entry.value).value.text;
>                             break;
>
>                         case
> AttributeType.AVERAGE_TARGETED_MONTHLY_SEARCHES:
>                             monthlySearches =
> ((LongAttribute)entry.value).value;
>                             break;
>
>                     }
>                     dict.Add(keyword1, monthlySearches);
>
>                 }
>
>             }

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