重复规则无效?

这是我使用cURL以下方法传递给 Google Calendar API 的有效负载:


["start"]=>

  string(25) "2019-07-01T00:00:00+08:00"

  ["end"]=>

  string(25) "2019-07-16T00:00:00+08:00"

  ["title"]=>

  string(20) "Google Sync Weekly 4"

  ["description"]=>

  string(20) "Google Sync Weekly 4"

  ["recurrence"]=>

  string(44) "RRULE=WEEKLY;UNTIL=2019-07-16T00:00:00+08:00"

在 my 中new_event.php,我在其中处理此有效负载:


$event = new Google_Service_Calendar_Event(array(

            'summary' => $event['title'],

            'location' => !empty($event['location']) ? $event['location'] : '',

            'description' => $event['description'],

            'start' => array(

              'dateTime' => $event['start'],

              'timeZone' => 'Asia/Taipei',

            ),

            'end' => array(

              'dateTime' => $event['end'],

              'timeZone' => 'Asia/Taipei',

            ),

            'recurrence' => !empty($event['recurrence']) ? [$event['recurrence']] : [],

            'reminders' => array(

              'useDefault' => FALSE,

              'overrides' => array(

                array('method' => 'email', 'minutes' => 24 * 60),

                array('method' => 'popup', 'minutes' => 10),

              ),

            ),

          ));

这是值:


["recurrence"]=>

  array(1) {

    [0]=>

    string(44) "RRULE=WEEKLY;UNTIL=2019-07-16T00:00:00+08:00"

  }

我无法弄清楚我在这里做错了什么。任何提示?


海绵宝宝撒
浏览 134回答 1
1回答

MMTTMM

以下按预期工作:$event = [  'start' => "2019-07-01T00:00:00+08:00",  'end' => "2019-07-16T00:00:00+08:00",  'title' => "Google Sync Weekly 4",  'description' => "Google Sync Weekly 4",  'recurrence' => "RRULE:FREQ=WEEKLY;UNTIL=20190716T000000Z",];$event = new Google_Service_Calendar_Event(array(  'summary' => $event['title'],  'location' => !empty($event['location']) ? $event['location'] : '',  'description' => $event['description'],  'start' => array(    'dateTime' => $event['start'],    'timeZone' => 'Asia/Taipei',  ),  'end' => array(    'dateTime' => $event['end'],    'timeZone' => 'Asia/Taipei',  ),  'recurrence' => !empty($event['recurrence']) ? [$event['recurrence']] : [],  'reminders' => array(    'useDefault' => FALSE,    'overrides' => array(      array('method' => 'email', 'minutes' => 24 * 60),      array('method' => 'popup', 'minutes' => 10),    ),  ),));$service = new Google_Service_Calendar($client);$service->events->insert('primary', $event);问题是,正如错误消息所暗示的那样,您的重复规则格式不正确。规则应该以 为前缀,RRULE:并且必须遵循RFC 5545 中规定的规则。请密切注意有关时间戳和时区的部分。可以在API 文档站点的“创建重复事件”代码片段中找到格式正确的规则的基本示例。您还可以从日历 UI 创建一个循环,并通过 API 获取它以获取其他更定制的示例。
打开App,查看更多内容
随时随地看视频慕课网APP