Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何使用谷歌日历API';s函数_Php_Api_Google Calendar Api - Fatal编程技术网

Php 如何使用谷歌日历API';s函数

Php 如何使用谷歌日历API';s函数,php,api,google-calendar-api,Php,Api,Google Calendar Api,我试图使用谷歌日历API,但无法正确调用内置函数。供参考: $events = $service->events->listEvents('primary'); while(true) { foreach ($events->getItems() as $event) { echo $event->getSummary(); } $pageToken = $events->getNextPageToken(); if

我试图使用谷歌日历API,但无法正确调用内置函数。供参考:

$events = $service->events->listEvents('primary');

while(true) {
    foreach ($events->getItems() as $event) {
        echo $event->getSummary();
    }
    $pageToken = $events->getNextPageToken();
    if ($pageToken) {
        $optParams = array('pageToken' => $pageToken);
        $events = $service->events->listEvents('primary', $optParams);
    } else {
        break;
    }
}
此代码返回一个致命错误:

对非对象调用成员函数
getItems()


我不明白如何使用未由
New()

实例化的对象。您需要将这一行添加到代码中

$client->setUseObjects(true);

将其添加到下一行之前

$service = new apiCalendarService($client);

返回数组,但此处需要对象

$service->events->listEvents('primary');