athibanraj / gdata-java-client

Automatically exported from code.google.com/p/gdata-java-client
Apache License 2.0
0 stars 0 forks source link

Keyword Feed error in Webmaster API #391

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.I can run CrawlIssuefeed, messagefeed etc, But keyword feed returns me an 
error.

CODE:
site Id= http://www.mdanderson.org/

public void printKeywords(String siteId,WebmasterToolsService service){
  URL feedUrl;
  try {
    if (!siteId.endsWith("/")) {
      siteId = siteId.concat("/");
    }
    String encodedSiteId = URLEncoder.encode(siteId, "UTF-8");
    feedUrl = new URL("https://www.google.com/webmasters/tools/feeds/"
        + encodedSiteId + "/keywords/");
  } catch (UnsupportedEncodingException e) {
    System.out.println("Encoding not supported");
    return;
  } catch (MalformedURLException e) {
    System.out.println("Malformed URL");
    return;
  }

  // Retrieve the keywords feed from the URL
  KeywordsFeed feed;
  try {
  System.out.println(feedUrl);
    feed = service.getFeed(feedUrl, KeywordsFeed.class);
  } catch (ServiceException e) {
    System.out.println("Service error");
    return;
  } catch (IOException e) {
    System.out.println("IO Error");
    return;
  }

  // Print the Keywords feed
  System.out.println("Keywords: ");
  for (Keyword keyword : feed.getKeywords()) {
    System.out.print("\tSource: " + keyword.getSource());
    System.out.println("\tKeyword: " + keyword.getValue());
  }
  System.out.println("Number of keywords: " + feed.getKeywords().size());
}

What is the expected output? What do you see instead?
I need the list of keywords Google found on your site or in the anchor text of 
links to your site

What version of the product are you using? On what operating system?
gdata-samples.java-1.47.1

Error message as show below,
caused by com.google.gdata.util.ParseException: [Line 1, Column 1743, element 
wt:keyword] Missing required text content 
        at com.google.gdata.util.XmlParser.throwParseException(XmlParser.java:730) 
        at com.google.gdata.util.XmlParser.parse(XmlParser.java:693) 
        at com.google.gdata.util.XmlParser.parse(XmlParser.java:576) 
        at com.google.gdata.data.BaseFeed.parseAtom(BaseFeed.java:867) 
        at com.google.gdata.wireformats.input.AtomDataParser.parse(AtomDataParser.java :68) 
        at com.google.gdata.wireformats.input.AtomDataParser.parse(AtomDataParser.java :39) 
        at com.google.gdata.wireformats.input.CharacterParser.parse(CharacterParser.ja va:100) 
        at com.google.gdata.wireformats.input.XmlInputParser.parse(XmlInputParser.java :52) 
        at com.google.gdata.wireformats.input.AtomDualParser.parse(AtomDualParser.java :66) 
        at com.google.gdata.wireformats.input.AtomDualParser.parse(AtomDualParser.java :34) 
        at com.google.gdata.client.Service.parseResponseData(Service.java:2165) 
        at com.google.gdata.client.Service.parseResponseData(Service.java:2098) 
        at com.google.gdata.client.Service.getFeed(Service.java:1136) 
        at com.google.gdata.client.Service.getFeed(Service.java:1077) 
        at com.google.gdata.client.GoogleService.getFeed(GoogleService.java:662) 
        at com.google.gdata.client.Service.query(Service.java:1237) 
        at com.google.gdata.client.Service.query(Service.java:1178)
at 
sample.webmastertools.WebmasterToolsClient.runExamples(WebmasterToolsClient.java
:552)
at 
sample.webmastertools.WebmasterToolsClient.main(WebmasterToolsClient.java:663)
at 
sample.webmastertools.WebmasterToolsClient.printKeywords(WebmasterToolsClient.ja
va:667)

Original issue reported on code.google.com by magsa.k...@gmail.com on 8 Jun 2012 at 10:58

GoogleCodeExporter commented 9 years ago
Can you share the code for CrawlIssuefeed, messagefeed ? I am trying to write a 
C# code to do it but I always get a 400 bad request error. My syntax is just 
like what you have used above

Original comment by deshmukh...@gmail.com on 14 Feb 2013 at 4:49

GoogleCodeExporter commented 9 years ago
Has this issue been fixed already cause I'm also experiencing the same.

Original comment by jas...@elrdevpm.com on 9 May 2014 at 12:00