You can use the Google client library for PHP . He noted beta , but I found it easy to use, and it works great for simple uses of the Calendar.
I put a working example on GitHub.
If you prefer to use the code directly against the OAuth 2.0 API, I would recommend checking out Google Developers OAuth 2.0 Playgrounds .
- Select
Calendar API v3 in step 1. - In step 3, click
List possible operations and select List Events . Replace {calendarId} with your gmail.com email address.
This allows you to observe the authentication flow, starting with redirecting back to your application after the user authenticates and grants permissions using Google:
GET /oauthplayground/?code=4/xxxxxxxxxxxZL-nxhM_kxxxxxxxxxQ HTTP/1.1
POST /oauth2/v4/token HTTP/1.1 Host: www.googleapis.com Content-length: 233 content-type: application/x-www-form-urlencoded user-agent: google-oauth-playground code=4%2FxxxxxxxxxxxxxxZL-xxxx_kxxxxxxxxxxQ&redirect_uri=https%3A%2F%2Fdevelopers.google.com%2Foauthplayground&client_id=4xxxxxxxxxx.apps.googleusercontent.com&client_secret=************&scope=&grant_type=authorization_code
GET /calendar/v3/calendars/ user@gmail.com /events HTTP/1.1 Host: www.googleapis.com Content-length: 0 Authorization: Bearer ya29.GlsBBUxxxxxxxxxxXo-dF-Kexxxxxxxxxxxx0j_owVSaxxxxxxxxxWG-Xxxxxxxxxl
source share