0

I'm finally able to get an Access Token, now I'm very confused as how to add a Calendar using only Google's provided apiClient.

$apiClient = SiteController::getApiClient();

$service = new apiCalendarService($apiClient);

$calendar = new Calendar();
$calendar->description = "What";

$service->calendars->insert($calendar);

This produces:

Error calling POST https://www.googleapis.com/calendar/v3/calendars?key=mykey: (400) Required

Is there some documentation/examples on adding a Calendar? There are a ton of examples, it seems like, for simply adding an Event.


I'm a little closer now, I get

apiServiceException

Error calling POST 

https://www.googleapis.com/calendar/v3/users/me/calendarList?key=mykey: (404) Not Found

Using the boilerplate code they gave on the documentation

$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

How do I change my request URL from

https://www.googleapis.com/calendar/v3/users/me/calendarList?key=mykey

to

https://www.googleapis.com/calendar/v3/calendars

This worked: // Create new calendar $apiClient = SiteController::getApiClient();

        $service = new apiCalendarService($apiClient);

        $calendar = new Calendar();
        $calendar->setSummary(Home::model()->count() . '-' . $model->name);

        $createdCalendar = $service->calendars->insert($calendar);
Community
  • 1
  • 1
Eric Carmichael
  • 560
  • 4
  • 15
  • thanks, this helped me alot. What does this say about the doc. I did what you did and tried to use the boilerplate code they gave on the documentation and got the exact same error. How did you find the way you are doing it here that works? – randy Aug 15 '12 at 15:28

1 Answers1

0

You can reference Google Calendar API v1 Developers' Guide.

Tom
  • 316
  • 2
  • 9
  • 30
  • Thanks, this really helped me out [Google Api, CalendarList->Insert](https://developers.google.com/google-apps/calendar/v3/reference/calendarList/insert) – Eric Carmichael Jun 28 '12 at 08:28