使用日历API时,源标题和网址未在Google日历中显示

时间:2018-01-07 07:34:06

标签: python google-calendar-api

使用Google Calendar的api和python,我添加了一个带有源URL的事件。它不会在网络上显示源网址的标题,也不会在Google日历的Android应用中显示网址。我的代码有问题吗?或者,谷歌日历中是否有错误?

event on web version

这是我使用的源参数:

'source': {
    'url': 'https://www.nps.gov/grte/planyourvisit/bcres.htm',
    'title': 'NPS Permit website'
  },

这是我的整个代码:

from __future__ import print_function
from datetime import date, timedelta
import datetime
import calendar
import httplib2
import os
from apiclient import discovery
from oauth2client import client
from oauth2client import tools
from oauth2client.file import Storage

try:
  import argparse
  flags = argparse.ArgumentParser(parents=[tools.argparser]).parse_args()
except ImportError:
flags = None

def get_credentials():
  home_dir = os.path.expanduser('~')
  credential_dir = os.path.join(home_dir, '.credentials')
  if not os.path.exists(credential_dir):
    os.makedirs(credential_dir)
  credential_path = os.path.join(credential_dir,
                               'calendar-python-quickstart.json')

  store = Storage(credential_path)
  credentials = store.get()
  if not credentials or credentials.invalid:
    flow = client.flow_from_clientsecrets(CLIENT_SECRET_FILE, SCOPES)
    flow.user_agent = APPLICATION_NAME
    if flags:
      credentials = tools.run_flow(flow, store, flags)
    else: # Needed only for compatibility with Python 2.6
      credentials = tools.run(flow, store)
    print('Storing credentials to ' + credential_path)
  return credentials

def main():  
  credentials = get_credentials()
  http = credentials.authorize(httplib2.Http())
  service = discovery.build('calendar', 'v3', http=http)

  cal_id  = 'h44h6fptkt81d36n4rapm9snrs@group.calendar.google.com'

  cal_body = {
    'start': {
      'date': '2018-01-03',
      'timeZone': 'America/Los_Angeles'
    },
    'end': {
      'date': '2018-01-03',
      'timeZone': 'America/Los_Angeles'
    },
    'summary': 'Event Title',
    'source': {
      'url': 'https://www.nps.gov/grte/planyourvisit/bcres.htm',
      'title': 'NPS Permit website'
    }, 
    'recurrence': ['RRULE:FREQ=YEARLY;BYMONTH=1;BYSETPOS=1;BYDAY=WE']
  }

  event = service.events().insert(calendarId=cal_id,body=cal_body ).execute()
  print(cal_body)

1 个答案:

答案 0 :(得分:1)

是的,这看起来像Google Calendar API中的错误。您可以在此处的问题跟踪器中找到此错误:https://issuetracker.google.com/issues/73334552