Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google calendar api 将事件添加到Google日历_Google Calendar Api - Fatal编程技术网

Google calendar api 将事件添加到Google日历

Google calendar api 将事件添加到Google日历,google-calendar-api,Google Calendar Api,我们正在使用谷歌API开发应用程序。在这个过程中,我们遇到了一些困难 我们使用了这个页面上的php sdk code.google.com/p/google-api-php-client/我们使用了google日历服务。我们遵循了这里的文档:developers.google.com/google-apps/calendar/v3/reference/sections Calendars and Events 源数据:-允许访问位于此处的Google日历服务code.Google.com/api

我们正在使用谷歌API开发应用程序。在这个过程中,我们遇到了一些困难

我们使用了这个页面上的php sdk code.google.com/p/google-api-php-client/我们使用了google日历服务。我们遵循了这里的文档:developers.google.com/google-apps/calendar/v3/reference/sections Calendars and Events

源数据:-允许访问位于此处的Google日历服务code.Google.com/api/console/-根据此处的文档请求所需的用户授权:developers.Google.com/Google-apps/Calendar/v3/reference/events/insert

任务:将事件添加到日历。 操作:我们将Post请求发送到{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"

}
注意:为了形成事件对象,我们使用了与这里示例相同的代码developers.google.com/google-apps/calendar/v3/reference/events/insert section Examples

Result: API returns an error with code 400 (Bad Request)
来自API的带有标题的回答


使用此工具进行游戏。我也有同样的问题。它在浏览器中工作,但在我的rails服务器上不工作


您在Google日历API的REST接口上提到的文档。然而,PHP客户端库的工作方式不同,不幸的是,它几乎没有文档记录

我使用了GooglePHPAPI客户端附带的示例。您需要在Google的API控制台中生成oAuth客户机ID、secret等。API客户机的文档中记录了它的工作原理

关于calendar PHP API的所有其他文档仅在Google_CalendarService类的注释中提供:

您可以使用以下代码将新事件添加到Google日历:

$event=新的Google_事件; //活动名称和地点 $event->setSummary'event title'; $event->setLocation'Some location'; //事件的开始和结束时间 $start=new Google\u EventDateTime; $start->setDateTime'2013-08-08T14:00:00+02:00'; $event->setStart$start; $stop=新的谷歌事件日期时间; $stop->setDateTime'2013-08-08T16:00:00+02:00'; $event->setEnd$stop; //在日历中插入事件。 //“primary”可以替换为完整的@group.calendar.google.com日历ID。 $createdEvent=$cal->events->insert'primary',$event;
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"

 } 

}