Google Tasks API现在可用。您可以通过HTTP查询获取任务列表,结果以JSON形式返回。有关于如何在
http://code.google.com/appengine/articles/python/getting_started_with_tasks_api.html
样品的webapp写在谷歌应用程序引擎谷歌的任务Web应用程序一步步的例子是这样的:
from google.appengine.dist import use_library
use_library('django', '1.2')
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template
from google.appengine.ext.webapp.util import run_wsgi_app
from apiclient.discovery import build
import httplib2
from oauth2client.appengine import OAuth2Decorator
import settings
decorator = OAuth2Decorator(client_id=settings.CLIENT_ID,
client_secret=settings.CLIENT_SECRET,
scope=settings.SCOPE,
user_agent='mytasks')
class MainHandler(webapp.RequestHandler):
@decorator.oauth_aware
def get(self):
if decorator.has_credentials():
service = build('tasks', 'v1', http=decorator.http())
result = service.tasks().list(tasklist='@default').execute()
tasks = result.get('items', [])
for task in tasks:
task['title_short'] = truncate(task['title'], 26)
self.response.out.write(template.render('templates/index.html',
{'tasks': tasks}))
else:
url = decorator.authorize_url()
self.response.out.write(template.render('templates/index.html',
{'tasks': [],
'authorize_url': url}))
def truncate(string, length):
return string[:length] + '...' if len(string) > length else string
application = webapp.WSGIApplication([('/', MainHandler)], debug=True)
def main():
run_wsgi_app(application)
注意,首先你需要启用Google API Tasks API https://code.google.com/apis/console/b/0/?pli=1
也许吧。你有什么尝试?对不起,SO不是'requirements => code'引擎。 – 2010-04-01 21:59:35
我试图做一个greasmonkey/jquery脚本.hide()所有不必要的日历div,但我不喜欢这个解决方案(它的脆弱)。我试着看看谷歌日历js代码,了解ajax调用,但它太复杂了。如果有更简单/干净的方式来访问我的数据,那就太好了。 – ideotop 2010-04-01 22:24:42