如何使用带有官方PHP库的Google Calendar API创建全天活动? [英] How to create allday events with Google Calendar API with official PHP Library?

查看:60
本文介绍了如何使用带有官方PHP库的Google Calendar API创建全天活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有此代码:

$event = new Event();
$event->setSummary( $_event['summary'] );
$event->setLocation( $_event['location'] );
$start = new EventDateTime();
$start->allDay = true;
$start->setDateTime($_event['start']);
$event->setStart($start);
$cal->events->insert( $_calendar['id'], $event  );

但无效= \

有什么主意吗?

推荐答案

如果要创建为期一天的事件,请使用$ start-> setDate()而不是$ start-> setDateTime().

Use $start->setDate() instead of $start->setDateTime() if you want to create a day long event.

要创建为期一天的活动

$event = new Event();
$event->setSummary("Summary of the event");
$event->setLocation("Location");

$start = new EventDateTime();
$start->setDate("2013-01-01"); 
$event->start=$start;

$end = new EventDateTime();
$end->setDate("2013-01-02");
$event->end=$end;

$calendarId="primary"; // primary represents your calendar
$createdEvent = $cal->events->insert($calendarId, $event);

要在给定的持续时间内创建事件

To create a event in a given duration

$event = new Event();
$event->setSummary("Summary of the event");
$event->setLocation("Location");

$start = new EventDateTime();
$start->setDateTime("2013-01-01T0:00:00.000+00:00");
$event->start=$start;

$end = new EventDateTime();
$end->setDateTime("2013-01-01T0:01:00.000+00:00");
$event->end=$end;

$calendarId="primary";
$createdEvent = $cal->events->insert($calendarId, $event);

这篇关于如何使用带有官方PHP库的Google Calendar API创建全天活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆