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