Google Calendar API PHP - 缺少摘要&说明

时间:2016-09-24 04:06:48

标签: php api calendar summary

尝试使用以下代码获取事件摘要和说明但没有运气。我甚至使用过Googles的API Explorer,但似乎无法通过API调用来返回此信息。知道我可能会缺少什么吗?另外,如果有任何我需要澄清的情况,请告诉我。在此先感谢您的帮助。一切顺利。

require_once 'google-api-php-client/src/Google/autoload.php';

$client = new Google_Client(); 
$client->setApplicationName("Application Name Hidden Here"); 
$client->setDeveloperKey("API_KEY_HIDDEN_HERE");

$service = new Google_Service_Calendar($client); 

$calendarId = 'media@meditationincolorado.org';
$optParams = array(
  'maxResults' => 3,
  'orderBy' => 'startTime',
  'singleEvents' => TRUE,
  'timeMin' => date('c')
);
$results = $service->events->listEvents($calendarId, $optParams);

if (count($results->getItems()) == 0) {
  print "No upcoming events found.<br/>";
} else {
  print "Upcoming events:<br/>";
  foreach ($results->getItems() as $event) {
    $summary = $event->getSummary();
    if (empty($start)) {
      $start = $event->start->date;
    }
    echo $summary . '<br/>';
  }
}

0 个答案:

没有答案