Мы разрабатываем приложение с использованием API Google. Во время этого процесса мы столкнулись с некоторыми трудностями.Добавление события в Календарь Google
Мы использовали php-sdk, который находится на этой странице «code.google.com/p/google-api-php-client/» Мы использовали сервис Календаря Google. Мы следовали документации, расположенной здесь: разделы «developers.google.com/google-apps/calendar/v3/reference/» Календари и события.
Исходные данные: доступ к сервису Календаря Google, указанному здесь, «code.google.com/apis/console/» - запрашивается запрашиваемая авторизация пользователя (на основе документации здесь: «developers.google.com/google- apps/calendar/v3/reference/events/insert) "
Задача: Добавление события в календарь. Действие: Мы посылаем сообщение-запрос на https://www.googleapis.com/calendar/v3/calendars/ {calendarId}/события calendarId = {calendarId} & альт = JSON & ключ = {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"
}
Примечание: Для того, чтобы сформировать объект события, которые мы использовали код (такой же, как в примере здесь developers.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"
}
}