US Home
Automation
(Last updated: Monday Sept. 07, 2009)
Automation
(Last updated: Monday Sept. 07, 2009)
Google Data Notes
I've started to work with the Google Data APIs and Groovy (though I'm pretty sure I could work the APIs in any language).
// This is currently setup to be loaded into groovysh
// It's sloppy and not following standards, I should clean it up
import com.google.common.collect.Maps;
import com.google.gdata.client.*;
import com.google.gdata.client.GoogleService;
import com.google.gdata.client.GoogleService.*;
import com.google.gdata.client.calendar.*;
import com.google.gdata.client.calendar.CalendarService;
import com.google.gdata.client.calendar.CalendarService.*;
import com.google.gdata.data.*;
import com.google.gdata.data.extensions.*;
import com.google.gdata.util.*;
import java.net.URL;
id = new String("usedid@gmail.example.com");
ps = new String("passW0rd");
// Set up the URL and the object that will handle the connection:
feedUrl = new URL("http://www.google.com/calendar/feeds/${id}/private/full");
myService = new CalendarService("exampleCo-exampleApp-1");
myService.setUserCredentials(id, ps);
// Mark the feed as an Event feed:
new EventFeed().declareExtensions(myService.getExtensionProfile());
// Send the request and receive the response:
resultFeed = myService.getFeed(feedUrl, Feed.class);
System.out.println("Your calendars:\n");
for (int i = 0; i < resultFeed.getEntries().size(); i++) {
entry = resultFeed.getEntries().get(i);
System.out.println("\t" + entry.getTitle().getPlainText());
}
There are prerequisites, that being the Google gdata jar and the Google Collect jar. You'll also need a valid Gmail id and password.
Links
- Google Data API - Google's API to their various online services and data.