title: Google API Calendar with Cron
body: <p>I am trying to access to a calendar created by my application via cron, and I get a calendar with the same name that the calendar the application creates, but the id is absolutely different... This is my code:</p>
  
  <pre><code>public function cronTest()
  {
      $this-&gt;g_client = new Google_Client();
      $this-&gt;g_client-&gt;setApplicationName($this-&gt;config-&gt;item("APPLICATION_NAME"));
      $service    = $this-&gt;getCronService("CalendarTest-46bde015a16.p12");
      $calendar   = $this-&gt;getCalendar($service);
  }
  private function getCronService($file)
  {
      $key  = file_get_contents(CREDENTIALS_PATH.$file); 
      $cred = new Google_Auth_AssertionCredentials($this-&gt;config-&gt;item("google_service_id"), SCOPES, $key);
      $this-&gt;g_client-&gt;setAssertionCredentials($cred);
      if($this-&gt;g_client-&gt;getAuth()-&gt;isAccessTokenExpired())
           $this-&gt;g_client-&gt;getAuth()-&gt;refreshTokenWithAssertion($cred);
      return new Google_Service_Calendar($this-&gt;g_client);
  }
  private function getCalendar($service)
  {
      $calendarList = $service-&gt;calendarList-&gt;listCalendarList();
      echo "getCalendar&lt;br&gt;";
      foreach ($calendarList-&gt;getItems() as $calendarListEntry)
      {
          echo $calendarListEntry-&gt;getSummary()." with id:".$calendarListEntry-&gt;getId()."&lt;br&gt;";
          echo "&lt;br&gt;";
          if($calendarListEntry-&gt;getSummary()=="Auto-Citas")
              echo "found";
              //return $calendarListEntry-&gt;getId();
      }
      die;
  }
  </code></pre>
  
  <p>When I execute it from the command line (simulating the cron):</p>
  
  <pre><code>wget www.domain.com/prototipo/alien/cronTest
  </code></pre>
  
  <p>I get this:</p>
  
  <pre><code>Calendar  
  Auto-Citas with id:h0gefmo7vjqlr4lp0r2n93vk9c@group.calendar.google.com  
  found
  </code></pre>
  
  <p>But, the id of calendar created with this application doesn´t match with this id...<br>
  Before this attempt with ron, I had to learn how to use the API, in this way I needed to remove sometimes the same calendar. So what I do, was remove one more time the Auto-Citas on my calendar, and call the function on my app to create a new calendar with a different name, then I made again the request of the "simulated cron" (wget www.domain.com/prototipo/alien/cronTest) and the result is the same than before: only one calendar called Auto-Citas, but nothing about the new calendar.<br>
  The functionality is to create a module anti-absenteeism, sending an email or sms to the user two hours before the appointment(cita=appointment)<br>
  For this tasks I have to function more... but they aren´t important for the case: </p>
  
  <pre><code>$events     = $this-&gt;getDates($service,$calendar,$min,$max);
  $this-&gt;transformDates($events, $service, ",phone");
  </code></pre>