繁体   English   中英

如何使用php在Google日历中创建事件(Codeigniter)

[英]how to create event in google calendar using php (Codeigniter)

我已经尝试使用php(Codeigniter)在Google日历中创建事件,但无法正常工作,请检查我下面的php(Codeigniter)代码

require_once APPPATH.'third_party/src/Google_Client.php';
require_once APPPATH.'third_party/src/contrib/Google_CalendarService.php';

$event = new Google_Event();
$service = new Google_CalendarService($event);
$event->setSummary('Appointment');
$event->setLocation('Somewhere');
$start = new Google_EventDateTime();
$start->setDateTime('2017-09-03T10:00:00.000-07:00');
$event->setStart($start);
$end = new Google_EventDateTime();
$end->setDateTime('2017-09-03T10:25:00.000-07:00');
$event->setEnd($end);
$attendee1 = new Google_EventAttendee();


$createdEvent = $service->events->insert('My calendar Email', $event);

尝试使用Calendar API的PHP快速入门示例作为参考,因为Codeigniter也使用PHP。 但是,此演示仅显示如何获取事件列表。 要创建事件,请使用Create Events中的PHP实现:

$event = new Google_Service_Calendar_Event(array(
  'summary' => 'Google I/O 2015',
  'location' => '800 Howard St., San Francisco, CA 94103',
  'description' => 'A chance to hear more about Google\'s developer products.',
  'start' => array(
    'dateTime' => '2015-05-28T09:00:00-07:00',
    'timeZone' => 'America/Los_Angeles',
  ),
  'end' => array(
    'dateTime' => '2015-05-28T17:00:00-07:00',
    'timeZone' => 'America/Los_Angeles',
  ),
  'recurrence' => array(
    'RRULE:FREQ=DAILY;COUNT=2'
  ),
  'attendees' => array(
    array('email' => 'lpage@example.com'),
    array('email' => 'sbrin@example.com'),
  ),
  'reminders' => array(
    'useDefault' => FALSE,
    'overrides' => array(
      array('method' => 'email', 'minutes' => 24 * 60),
      array('method' => 'popup', 'minutes' => 10),
    ),
  ),
));

$calendarId = 'primary';
$event = $service->events->insert($calendarId, $event);
printf('Event created: %s\n', $event->htmlLink);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM