Quantcast
Channel: Using the Google API Java Client to parse publicly shared Calendar RSS feeds - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by youdonotexist for Using the Google API Java Client to parse publicly shared Calendar RSS feeds

$
0
0

I found the solution. A good example of this can been seen with the current YouTube example on the Google Api Java Client example.

http://code.google.com/p/google-api-java-client/wiki/SampleProgram

The missing part of the puzzle was having to:

  1. Extend the GoogleUrl class (I used CalendarUrl)
  2. Create objects that match the jsonc output of thefeed (you can get the jsonc output by appending &alt=jsonc to theend of the feed URL)
  3. Annotate (@Key("NameOfField")) the objects from step 2 to match jsonc names

Once you've done that, the following code will build and get everything that you need:

HttpTransport transport = new NetHttpTransport();final JsonFactory jsonFactory = new JacksonFactory();HttpRequestFactory factory = transport.createRequestFactory(new HttpRequestInitializer() {        @Override        public void initialize(HttpRequest request) {            // set the parser            JsonCParser parser = new JsonCParser(jsonFactory);            request.addParser(parser);            // set up the Google headers            GoogleHeaders headers = new GoogleHeaders();            headers.setApplicationName("Google-CalendarSample/1.0");            headers.gdataVersion = "2";            request.setHeaders(headers);        }});CalendarUrl url = new CalendarUrl(YOUR_FEED_URL);HttpRequest request = factory.buildGetRequest(url);CalendarFeed feed = request.execute().parseAs(CalendarFeed.class);

Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>