title: How to Define which Calendar to Connect to using Google Calendar API v3 Service
body: <p>I am trying to list all the events in a certain public calendar in a nicely formatted manner on my web page without having a general/public visitor to my web site login or authenticate in any way. I have been doing this since December 2010 using v1 and the Zend Framework. On November 17, 2014 Google deprecated v1 and v2 and now my web page is broken.</p>
  
  <p><strong>Here is what I've done so far:</strong></p>
  
  <ol>
  <li>created a project in the Google Developer's Console</li>
  <li>turned on Calendar API</li>
  <li>installed PHP Client Library on my server from GitHub (yesterday - release 1.1.1)</li>
  <li>ensured JSON PHP Extension is installed on my server</li>
  <li>created OAuth 2.0 credentials</li>
  <li>created Public API Access key</li>
  <li>ensured my calendars are still publicly viewable (they have been since December 2010)</li>
  </ol>
  
  <p><strong>Here is my code snippet:</strong></p>
  
  <pre><code>require_once 'autoload.php'; // 2014-11-24 part of /usr/local/lib/php/google-api-php-client
  $client = new Google_Client();
  $client-&gt;setApplicationName("One_of_my_Calendars");
  $client-&gt;setDeveloperKey("MY-PUBLIC-API-ACCESS-KEY"); // 2014-11-24 my Public API Access Key
  $service = new Google_Service_Calendar($client);
  $results = $service-&gt;events-&gt;listEvents('primary');
  </code></pre>
  
  <p><strong>Here is the error message I am getting:</strong></p>
  
  <pre><code>Fatal error: Uncaught exception 'Google_Service_Exception' with message 'Error calling GET https://www.googleapis.com/calendar/v3/calendars/primary/events?key=MY-PUBLIC-API-ACCESS-KEY: (403) Access Not Configured. The API is not enabled for your project, or there is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your configuration.' in /usr/local/lib/php/google-api-php-client/src/Google/Http/REST.php:76 Stack trace: #0 /usr/local/lib/php/google-api-php-client/src/Google/Http/REST.php(41): Google_Http_REST::decodeHttpResponse(Object(Google_Http_Request)) #1 /usr/local/lib/php/google-api-php-client/src/Google/Client.php(548): Google_Http_REST::execute(Object(Google_Client), Object(Google_Http_Request)) #2 /usr/local/lib/php/google-api-php-client/src/Google/Service/Resource.php(190): Google_Client-&gt;execute(Object(Google_Http_Request)) #3 /usr/local/lib/php/google-api-php-client/src/Google/Servi in /usr/local/lib/php/google-api-php-client/src/Google/Http/REST.php on line 76
  </code></pre>
  
  <p><strong>Screen Shots:</strong></p>
  
  <p><a href="https://drive.google.com/file/d/0Bytqhoir_Tt5ODRaNzRvS2FZRWs/view?usp=sharing" rel="nofollow">https://drive.google.com/file/d/0Bytqhoir_Tt5ODRaNzRvS2FZRWs/view?usp=sharing</a>
  <a href="https://drive.google.com/file/d/0Bytqhoir_Tt5MzlqLWF2Q3M2bUk/view?usp=sharing" rel="nofollow">https://drive.google.com/file/d/0Bytqhoir_Tt5MzlqLWF2Q3M2bUk/view?usp=sharing</a></p>