Hi David,
The below code iam using.
public class GetRelatedKeywords {
public static void main(String[] args) {
try {
// Log SOAP XML request and response.
AdWordsServiceLogger.log();
// Get AdWordsUser from "~/adwords.properties".
AdWordsUser user = new AdWordsUser();
String authToken = new AuthToken(user.getEmail(),
user.getPassword()).getAuthToken();
user.setAuthToken(authToken);
// Get the TargetingIdeaService.
TargetingIdeaServiceInterface targetingIdeaService =
user.getService(AdWordsService.V201101.TARGETING_IDEA_SERVICE);
// Create seed keyword.
Keyword keyword = new Keyword();
keyword.setText("Car");
keyword.setMatchType(KeywordMatchType.BROAD);
// Create selector.
TargetingIdeaSelector selector = new TargetingIdeaSelector();
selector.setRequestType(RequestType.IDEAS);
selector.setIdeaType(IdeaType.KEYWORD);
selector.setRequestedAttributeTypes(new AttributeType[]
{AttributeType.CRITERION,
AttributeType.AVERAGE_TARGETED_MONTHLY_SEARCHES});
// Set selector paging (required for targeting idea service).
Paging paging = new Paging();
paging.setStartIndex(0);
paging.setNumberResults(10);
selector.setPaging(paging);
// Create related to keyword search parameter.
RelatedToKeywordSearchParameter relatedToKeywordSearchParameter
=
new RelatedToKeywordSearchParameter();
relatedToKeywordSearchParameter.setKeywords(new Keyword[]
{keyword});
// Create keyword match type search parameter to ensure unique
results.
KeywordMatchTypeSearchParameter keywordMatchTypeSearchParameter
=
new KeywordMatchTypeSearchParameter();
keywordMatchTypeSearchParameter
.setKeywordMatchTypes(new KeywordMatchType[]
{KeywordMatchType.BROAD});
selector.setSearchParameters(new SearchParameter[]
{relatedToKeywordSearchParameter,
keywordMatchTypeSearchParameter});
// Get related keywords.
TargetingIdeaPage page = targetingIdeaService.get(selector);
// Display related keywords.
if (page.getEntries() != null && page.getEntries().length > 0) {
for (TargetingIdea targetingIdea : page.getEntries()) {
Map<AttributeType, Attribute> data =
MapUtils.toMap(targetingIdea.getData());
keyword = (Keyword) ((CriterionAttribute)
data.get(AttributeType.CRITERION)).getValue();
Long averageMonthlySearches =
((LongAttribute)
data.get(AttributeType.AVERAGE_TARGETED_MONTHLY_SEARCHES))
.getValue();
System.out.println("Keyword with text '" + keyword.getText()
+ "', match type '"
+ keyword.getMatchType() + "', and average monthly
search volume '"
+ averageMonthlySearches + "' was found.");
}
} else {
System.out.println("No related keywords were found.");
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
Please provide me the sample java code for access the SandBox
URL(https://adwords-sandbox.google.com/).
I'm stuck and not sure what I'm doing wrong. It would be great if
someone could point me in the right direction.
Thanks in advance
Santhosh.A
On Oct 24, 6:21 pm, David Torres <[email protected]> wrote:
> Hi Santhosh,
>
> Could you post the snippet of your code that is throwing the error? I'll be
> glad to look at it and point out any issues.
>
> Best,
>
> -David Torres - AdWords API Team
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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