API Googleを使用してアプリケーションを開発しています。この過程で我々はいくつかの困難に直面した。Googleカレンダーにイベントを追加する
このページにあるphp-sdkを使用しました。「code.google.com/p/google-api-php-client/」Googleカレンダーサービスを使用しました。 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} & ALT = jsonを&キー= {APIキー}
リクエストボディ:?
{
"\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"
}
注:形成するためにイベントの目的我々は(APIから(この例ではここでdevelopers.google.com/google-apps/calendar/v3/reference/events/insert部分例と同じ)コード
Result: API returns an error with code 400 (Bad Request)
回答を使用ヘッダー付き)
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"
}
}