0

由于 gmail 和任务 api 并非随处可用(例如:一些公司阻止 gmail 但不阻止日历),有没有办法通过日历网络界面废弃 google 任务?

我做了一个像下面这样的用户脚本,但我觉得它太脆弱了:

// List of div to hide
idlist = [
    'gbar',
    'logo-container',
    ...
];

// Hiding by id
function displayNone(idlist) {
    for each (id in idlist) {
        document.getElementById(id).style.display = 'none';
    }
}
4

2 回答 2

1

Google Tasks API 现在可用。您可以通过 HTTP 查询获取任务列表,结果以 JSON 格式返回。有关如何在 Google App Engine 上编写 Google Tasks webapp 的分步示例,请访问

http://code.google.com/appengine/articles/python/getting_started_with_tasks_api.html

示例 webapp 如下所示:

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)

请注意,首先您需要在 API 控制台https://code.google.com/apis/console/b/0/?pli=1启用 Google Tasks API

于 2011-09-09T10:16:16.803 回答
0

我建议解析您希望查看的日历的 Atom 提要。您可以通过选择“选项齿轮”>“日历设置”,然后选择“日历”选项卡并选择所需的日历来获取各个日历的提要。从日历详细信息屏幕中,您可以获得 Atom (XML) 提要、iCal 提要或 HTML/Javascript 日历。

于 2011-03-21T13:39:43.777 回答