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 Entry
{
@Key
String title
@Key
String content
}
// フィード
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();
query = 'meeting'
request.url =
"http://www.google.com/calendar/feeds/default/private/full" +
"?q=${URLEncoder.encode(query, "UTF-8")}"
feed = request.execute().parseAs( Feed.class)
println "feed title:" + feed.title
for(item in feed.entry){
println "title:" + item.title
println "content:" + item.content
}
動作環境
groovy 1.7.2, JDK6 Update20, gdata-java-2.2.1-alpha
関連情報
gdata-java-client
http://code.google.com/p/gdata-java-client/
0 件のコメント:
コメントを投稿