[FYI] GData が使いやすくなりました

25 views
Skip to first unread message

tmatsuo

unread,
Jun 27, 2008, 10:44:35 PM6/27/08
to Google-App-Engine-Japan

松尾です。

Data APIs Blog[1] に GData API が使いやすくなったという記事[2] がポスト
されました。

1. http://googledataapis.blogspot.com/
2. http://googledataapis.blogspot.com/2008/06/google-data-apis-now-easier-to-use-for.html

当グループの日本語リソースページ[3] に紹介している「Google App Engine
上で認証が必要な Google Data Feeds を取得する方法」[4] では、GAE 上で認
証が必要な GData Service Feed を取得する方法を紹介しました。

3. http://groups.google.com/group/google-app-engine-japan/web/%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%AA%E3%82%BD%E3%83%BC%E3%82%B9
4. http://mars.shehas.net/%7Etmatsuo/misc/gdata-ja.html

この方法は便利でしたが、今までは一度のオペレーションでひとつの GData
Service に対してしかアクセス許可を行えませんでした。ところが今回の変更
で複数のサービスに対して一度にアクセス許可を行えるようになったようです。
これでマッシュアップがしやすくなりますね。

ちょっと試してみました。上記記事[4] の step1.py を少し変更して、
Blogger とカレンダーに対して同時にアクセス許可をリクエストするようにし
てみたコードをメール末尾に付けます。はじめの authsub_url のところでは複
数の URL を %20 で区切り、GenerateAuthSubURL の第二引数では スペースで
区切るとうまく行くようです。

Happy coding :-)

-- Takashi Matsuo

---- from here ----
import wsgiref.handlers
from google.appengine.ext import webapp
import gdata.service

class Fetcher(webapp.RequestHandler):
def get(self):
# Instantiate an instance of the
GDataService()
client = gdata.service.GDataService()

authsub_url = ('http://tm-test-app.appspot.com/step1' +
'?token_scope=http://www.blogger.com/feeds/%20' +
'http://www.google.com/calendar/feeds')

# Generate the AuthSub URL and write a page that includes the
link

self.response.out.write("""<html><body>
<a href="%s">Request token for the Blogger Scope</
a>
</body></html>""" % client.GenerateAuthSubURL(authsub_url,
'http://
www.blogger.com/feeds/ http://www.google.com/calendar/feeds',
secure=False,
session=True))

def main():
application = webapp.WSGIApplication([('/.*', Fetcher),],
debug=True)
wsgiref.handlers.CGIHandler().run(application)

if __name__ == '__main__':
main()
---- to here ----


Takashi Matsuo

unread,
Jun 27, 2008, 10:52:21 PM6/27/08
to Google-App-Engine-Japan
松尾です。

嗚呼、メールが折り返されて python code が...
コードを添付で送り直しますね。

step1.py
Reply all
Reply to author
Forward
0 new messages