使用apiClient添加Google日历

时间:2012-06-28 01:37:39

标签: php insert google-calendar-api

我终于能够获得一个访问令牌,现在我很困惑如何只使用Google提供的apiClient添加日历。

$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

如何从

更改请求网址
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);

1 个答案:

答案 0 :(得分:0)