我正在使用python客户端库向Google Calendar API发出请求。它工作正常,但我没有在日历上获得所有事件。但是,如果我查看API资源管理器,我会以不同的格式获取所有内容。例如,API资源管理器包含我需要的“摘要”键。那是为什么?
credentials = ServiceAccountCredentials.from_json_keyfile_name(SERVICE_ACCOUNT_JSON_FILE_PATH, scopes)
http_auth = credentials.authorize(Http())
calendar = build('calendar', 'v3', credentials=credentials)
currentTime = datetime.datetime.now()
maxTime = currentTime + relativedelta(months=+1)
#do this to get all events on this day
maxTime = maxTime.replace(minute=59, hour=23, second=59)
currentTime = currentTime.isoformat('T') + '-06:00'
maxTime = maxTime.isoformat('T') + '-06:00'
response = calendar.events().list(calendarId="*******", singleEvents=True, maxResults=2500, showHiddenInvitations=True, timeMin=currentTime, timeMax=maxTime).execute()
return JsonResponse(response)
答案 0 :(得分:0)
可以在Resource representations中找到Calendar API资源管理器的所有属性,包括" ' * '
"。现在,要在成功获得API请求后获取所有内容,请务必在q parameter中指定import json,tables
proc get_json_keys(json : JsonNode):OrderedTable[string,string]=
#initialize the result object
result = initOrderedTable[string,string]()
#more info,see https://nim-lang.org/docs/json.html
for key,value in json.pairs():
#debugging...
#echo key & "-" & value.getStr()
if not result.contains(key):
result[key]=value.getStr()
var json_data = parseJson("""{"key1" :"value1","key2" :"value2" }""")
var key_list = get_json_keys(json_data)
for key in key_list.pairs() :
echo key
,告诉Event.list您需要完整的响应。