我们正在使用 API Google 开发应用程序。在这个过程中,我们遇到了一些困难。
我们使用了此页面“code.google.com/p/google-api-php-client/”上的 php-sdk 我们使用了 Google 日历服务。我们遵循位于此处的文档:“developers.google.com/google-apps/calendar/v3/reference/”部分日历和事件。
源数据: - 允许访问位于此处的 Google 日历服务“code.google.com/apis/console/” - 请求所需的用户授权(基于此处的文档:“developers.google.com/google-apps/calendar/” v3/参考/事件/插入)”
任务:将事件添加到日历。行动:我们将 Post-Request 发送到https://www.googleapis.com/calendar/v3/calendars/ {calendarId}/events?calendarId={calendarId}&alt=json&key={API Key}
请求正文:
{
"\u0000*\u0000__creatorType":"EventCreator",
"\u0000*\u0000__creatorDataType":"",
"\u0000*\u0000__organizerType":"EventOrganizer",
"\u0000*\u0000__organizerDataType":"",
"\u0000*\u0000__attendeesType":"EventAttendee",
"\u0000*\u0000__attendeesDataType":"array",
"\u0000*\u0000__startType":"EventDateTime",
"\u0000*\u0000__startDataType":"",
"start":{
"date":"",
"timeZone":"Europe\/Moscow",
"dateTime":"2012-0408T12:00:00+04:00"
},
"location":"sdasdwqwqesaddsa",
"\u0000*\u0000__originalStartTimeType":"EventDateTime",
"\u0000*\u0000__originalStartTimeDataType":"",
"\u0000*\u0000__gadgetType":"EventGadget",
"\u0000*\u0000__gadgetDataType":"",
"description":"sadasdzxczxcasdsaweqqwasd",
"\u0000*\u0000__extendedPropertiesType":"EventExtendedProperties",
"\u0000*\u0000__extendedPropertiesDataType":"",
"\u0000*\u0000__endType":"EventDateTime",
"\u0000*\u0000__endDataType":"",
"end":{
"date":"",
"timeZone":"Europe\/Moscow",
"dateTime":"2012-04-08T19:00:00+04:00"
},
"\u0000*\u0000__remindersType":"EventReminders",
"\u0000*\u0000__remindersDataType":"",
"summary":"wqeqwesadasewqe"
}
注意:为了形成事件对象,我们使用了代码(与这里的示例开发者.google.com/google-apps/calendar/v3/reference/events/insert 部分示例中的示例相同)
Result: API returns an error with code 400 (Bad Request)
来自 API 的回答(带有标题)
HTTP/1.1 400 Bad Request Content-Type: application/json; charset=UTF-8 Date: Fri, 06 Apr 2012 05:53:55 GMT Expires: Fri, 06 Apr 2012 05:53:55 GMT Cache-Control: private, max-age=0 X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN X-XSS-Protection: 1; mode=block Server: GSE Transfer-Encoding: chunked
{ "error": {
"errors": [
{ "domain": "global",
"reason": "badRequest",
"message": "Bad Request" }
],
"code": 400,
"message": "Bad Request"
}
}