2017-02-09 92 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

,我發現我的問題其實我缺少一個步驟是共享服務帳戶的電子郵件日曆的解決方案。