我有一个用于创建Google日历活动的脚本php。 脚本正常工作,但设置日期错误的功能。
剧本他的
[...initial statements...]
$event = new Google_Event();
$event->setSummary("test");
$event->setLocation("location");
$start = new Google_EventDateTime();
$start->setDateTime(2014-05-01T10:00:00.000-07:00);
$event->setStart($start);
$end = new Google_EventDateTime();
$end->setDateTime(2014-05-01T10:00:00.000-08:00);
$event->setEnd($end);
$reminder = new Google_EventReminders();
$reminder->setUseDefault(false);
$overrides = array("method"=> "popup","minutes" => "15");
$reminder->setOverrides(array($overrides));
$event->setReminders($reminder);
$createdEvent = $service->events->insert('primary', $event);
[...]
在创建的事件中,我有两个提醒 电子邮件10分钟,弹出10分钟
答案 0 :(得分:1)
以下是我的工作方式:)
$event = new Google_Event(); //note in the API examples it calls Event(). Apparently, they changed it and didn't update examples.
$event->setSummary($task);
$event->setColorId('4');
$event->setDescription($type);
$event->setLocation($type);
$start = new Google_EventDateTime(); //note in the API examples it calls EventDateTime().
$start->setDateTime($date1);
$event->setStart($start);
$end = new Google_EventDateTime(); //note in the API examples it calls EventDateTime().
$end->setDateTime($date2);
$event->setEnd($end);
$attendee1 = new Google_EventAttendee(); //note in the API examples it calls EventAttendee().
$attendee1->setEmail('myemail@gmail.com'); //make sure you actually put an email address in here
$reminderI = new Google_EventReminder();
$reminderI->setMethod('email');
$reminderI->setMinutes('25');
$reminder = new Google_EventReminders();
$reminder->setUseDefault('false');
$reminder->setOverrides(array($reminderI));
$event->setReminders($reminder);
答案 1 :(得分:1)
我花了几分钟把它想出来,试试看:
$reminders = new Google_Service_Calendar_EventReminders();
$reminders->setUseDefault(false);
$reminder = new Google_Service_Calendar_EventReminder();
$method = empty($v['method']) ? 'email' : $v['method'];
$minute = empty($v['minute']) ? '10' : $v['minute'];
$reminder->setMethod($method);
$reminder->setMinutes($minute);
$reminders->setOverrides(array($reminder));
$targetEvent->setReminders($reminders);
请注意$reminders->setOverrides(array($reminder));
我们需要在调用$reminder
时将array
置于$reminders->setOverrides
我正在使用API V3,我想你正在使用V2。无论如何,它应该非常相似。
希望这有帮助。
答案 2 :(得分:0)
我认为问题在于:
$overrides = array("method"=> "popup","minutes" => "15");
您实际上是在array
中将数组包装在此处:
setOverrides(array($overrides));
override
应该是Google_Service_Calendar_EventReminder
类型的对象。