I\'d like to write some simple PHP code for a website, to get read-only access to a public Google calendar list of events using Google\'s calendar API V3. I simply need to d
I think you're way overthinking this one. If you just need access to events on a public calendar, then there's a way to do this without invoking the Google Calendar API and all of the attached complexity. Every public Google Calendar has an iCal feed that can be viewed at a specific URL, usually in the form of:
http://www.google.com/calendar/ical/{OWNER}/public/basic.ics
where {OWNER}
is the URL-encoded email address of the owner of the calendar.
You can find the specific URL by viewing the calendar settings and scrolling to the bottom of the Calendar Details tab.
Some tips to do this are embedded in the comments to Charles' answer. Anyway, as of 2014 (with Google Calendar v3 API), this is what I did:
Go here to see how the v3 API works:
https://developers.google.com/google-apps/calendar/v3/reference/events/list#try-it
Fill at least these three fields in the demo web form available on the above link:
calendarId
: the URL-encoded email address of the owner of the calendar.
timeMax
: End Time
timeMin
: Start Time
(Use this Time Format: 2014-05-04T00:00:00-00:00
(Y-m-d T millisecond - offset))
You'll see the following REQUEST being sent out.
GET https://www.googleapis.com/calendar/v3/calendars/{CALENDER_ID}/events?timeMax={start_time}&timeMin={end_time}&key={YOUR_API_KEY}
Now you can customize this request URL for your requirement and send regular GET requests from your code.
P.S -- To get your API Key, follow the procedure here:
https://developers.google.com/google-apps/calendar/auth