title: Google Calendar API v3 using PHP and REST
body: <p>We have been using google calendar to schedule some tasks and I would like to get data on the calendar for use on our internal website.</p>
  
  <p>I have created API key's and Client ID's, Client Secret etc. using the <a href="https://code.google.com/apis/console/" rel="nofollow">Google API Console</a> and I have enabled access to the Calendar API.. Now what PHP code should I use to request the calendar data over REST?</p>
  
  <p>Here's what I pieced together so far using <a href="https://developers.google.com/google-apps/calendar/downloads" rel="nofollow">Google's PHP client library</a>:</p>
  
  <pre><code>require_once $_SERVER['DOCUMENT_ROOT'].'/includes/google-api-php-client/src/Google_Client.php';
  require_once $_SERVER['DOCUMENT_ROOT'].'/includes/google-api-php-client/src/contrib/Google_CalendarService.php';
  session_start();
  
      $client = new Google_Client();
  
  $client-&gt;setApplicationName('My Application Name');
  
  $client-&gt;setClientId('my_client_id');
  $client-&gt;setClientSecret('my_client_secret');
  $client-&gt;setRedirectUri('my_oauth2_callback');
  $client-&gt;setDeveloperKey('my_developer_key');
  
  $cal = new Google_CalendarService($client);
  
  if (isset($_REQUEST['logout'])) {
    unset($_SESSION['access_token']);
  }
  
  // If the user has been redirected back to our page with an authorization code, exchange the code for an access token.
  if (isset($_GET['code'])) {
    $client-&gt;authenticate($_GET['code']);
    $_SESSION['access_token'] = $client-&gt;getAccessToken();
    header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
  }
  
  if (isset($_SESSION['access_token'])) {
    $client-&gt;setAccessToken($_SESSION['access_token']);
  }
  
  if ($client-&gt;getAccessToken()) {
      $calList = $cal-&gt;calendarList-&gt;listCalendarList();
      print "&lt;h1&gt;Calendar List&lt;/h1&gt;&lt;pre&gt;" . print_r($calList, true) . "&lt;/pre&gt;";
  
              // Here's where I need to do something to get the calendar data
  
      // We're not done yet. Remember to update the cached access token.
      // Remember to replace $_SESSION with a real database or memcached.
      $_SESSION['token'] = $client-&gt;getAccessToken();
  } else {
      $authUrl = $client-&gt;createAuthUrl();
      print "&lt;a href='$authUrl'&gt;Connect Me!&lt;/a&gt;";
  }
  </code></pre>
  
  <p>I want to be able to skip the "Connect Me!" authorization step. The user accessing the app might not have access to the shared calendar in Google but should still be able to view the data from the calendar in this app. </p>
  
  <p>I also have the Zend Framework installed on my server. I prefer a solution that doesn't need Zend but if it works I'll use it..</p>