我終於能夠獲得Access令牌,現在我很困惑如何僅使用Google提供的apiClient添加日曆。使用apiClient添加Google日曆
$apiClient = SiteController::getApiClient();
$service = new apiCalendarService($apiClient);
$calendar = new Calendar();
$calendar->description = "What";
$service->calendars->insert($calendar);
這將產生:
Error calling POST https://www.googleapis.com/calendar/v3/calendars?key=mykey: (400) Required
是否有添加日曆一些文檔/例子嗎?有很多例子,看起來像是簡單地添加一個事件。
我靠近一點,現在,我得到
apiServiceException
Error calling POST
https://www.googleapis.com/calendar/v3/users/me/calendarList?key=mykey: (404) Not Found
使用他們的文檔
$calendarListEntry = new CalendarListEntry();
$calendarListEntry->setId("calendarId");
$createdCalendarListEntry = $service->calendarList->insert($calendarListEntry);
echo $createdCalendarListEntry->getSummary();
Inserting a new calendarEntry in google calendar API v3 returns a 404
怎麼做了樣板代碼我改變了我的要求RL從
https://www.googleapis.com/calendar/v3/users/me/calendarList?key=mykey
到
https://www.googleapis.com/calendar/v3/calendars
這工作: //創建新日曆 $ apiClient = SiteController :: getApiClient();
$service = new apiCalendarService($apiClient);
$calendar = new Calendar();
$calendar->setSummary(Home::model()->count() . '-' . $model->name);
$createdCalendar = $service->calendars->insert($calendar);
謝謝,這幫助了我很多。這對於文檔有什麼意義。我做了你所做的,並嘗試使用他們在文檔中給出的樣板代碼,並得到了完全相同的錯誤。你是如何找到你在這裏工作的方式的? – randy