import com.google.api.client.googleapis.*
import com.google.api.client.googleapis.auth.clientlogin.*
import com.google.api.data.calendar.v2.*
import com.google.api.data.calendar.v2.atom.*
import com.google.api.client.xml.atom.*
import com.google.api.client.util.*;
// 著者
public class Author
{
@Key
String name
@Key
String email
}
// エントリ
public class Entry
{
@Key
String title
@Key
Author author
}
// フィード
public class Feed
{
@Key
String title
@Key
List<Entry> entry
}
// Parser設定
GoogleTransport transport = new GoogleTransport();
transport.applicationName = "yourcorp-yourapp-1.0";
transport.setVersionHeader(GoogleCalendar.VERSION);
ap = new AtomParser()
ap.namespaceDictionary = GoogleCalendarAtom.NAMESPACE_DICTIONARY
transport.addParser(ap);
username = "youraccount@gmail.com"
password = 'yourpassword'
// 認証
cl = new ClientLogin();
cl.authTokenType = GoogleCalendar.AUTH_TOKEN_TYPE;
cl.username = username;
cl.password = password
cl.authenticate().setAuthorizationHeader(transport);
// リクエスト
request = transport.buildGetRequest();
request.url = GoogleCalendar.ROOT_URL +"default/allcalendars/full"
feed = request.execute().parseAs( Feed.class)
println "feed title:" + feed.title
for(item in feed.entry){
println "title:" + item.title
println "author:" + item.author.name
println "email:" + item.author.email
}
動作環境
groovy 1.7.2, JDK6 Update20, gdata-java-2.2.1-alpha
関連情報
gdata-java-client
http://code.google.com/p/gdata-java-client/
0 件のコメント:
コメントを投稿