Google calendar API for PHP simple read-only request to get calendar events

前端 未结 2 790
鱼传尺愫
鱼传尺愫 2021-01-11 18:13

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

相关标签:
2条回答
  • 2021-01-11 18:53

    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.

    0 讨论(0)
  • 2021-01-11 18:56

    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

    0 讨论(0)
提交回复
热议问题