2017-02-09 55 views
0

谷歌日历API我想用谷歌日历API来接收所有谷歌calendars.Am的列表中,但它给出items.Here空是我的代码,我使用:越来越空,而使用在PHP

$client_id='#######.apps.googleusercontent.com'; 
$service_account_name = '#####'; 
$calName = '[email protected]'; 
$client = new Google_Client(); 
$client->setApplicationName("#####"); 
$service = new Google_Service_Calendar($client); 
$client->setAuthConfig('###########'); 
putenv('GOOGLE_APPLICATION_CREDENTIALS=##########'); 
$client->useApplicationDefaultCredentials(); 
$client->addScope(Google_Service_Calendar::CALENDAR); 

//for getting all calendars 
$calendarList = $service->calendarList->listCalendarList(); 
print_r($calendarList); 
while(true) { 
foreach ($calendarList->getItems() as $calendarListEntry) { 
echo $calendarListEntry->getSummary(); 
} 
$pageToken = $calendarList->getNextPageToken(); 
if ($pageToken) { 
$optParams = array('pageToken' => $pageToken); 
$calendarList = $service->calendarList->listCalendarList($optParams); 
} else { 
break; 
    } 
} 

和输出我得到:

Google_Service_Calendar_CalendarList Object ([collection_key:protected] => items [etag] => "p32off2tdka0d40g"  [itemsType:protected] => Google_Service_Calendar_CalendarListEntry [itemsDataType:protected] => array [kind] => calendar#calendarList [nextPageToken] => [nextSyncToken] => CLD3i62igNICEil4cGVydGVjaEBuZXcteHBlci5pYW0uZ3NlcnZpY2VhY2NvdW50LmNvbQ== [internal_gapi_mappings:protected] => Array () [modelData:protected] => Array ([items] => Array ()) [processed:protected] => Array ()) 
+0

永远不会提供您的详细信息question.People可以使用它不好的方式。小心,尽快取消凭据 –

回答

0

,我发现我的问题其实我缺少一个步骤是共享服务帐户的电子邮件日历的解决方案。