title: Google Calendar API create multiple events at once
body: <p>I'm completely stuck and no where there seems to be a guide.
  I want to add multiple Google Calendar events at once thru Batch Request. But I don't know where to start. I've tried the code from <a href="https://stackoverflow.com/questions/17840333/google-calendar-api-batch-request-php">Google Calendar API batch request PHP</a> from this site, but I don't understand it.</p>
  
  <p>I have  a form where I can select a month, year and for every day of the month a work appointment.</p>
  
  <p>The appointment is looked up in the database and returns start and end time.
  It's constructed in the Google DateTime.</p>
  
  <pre><code>if (isset($_POST['submit']))
  {
      $year = $_POST['year'];
      $month =$_POST['month'];
      $day1 = $_POST['1'];
      $day2 = $_POST['2'];
      $day3 = $_POST['3'];
  
      if($day1 !="")
      {
        //... database lookup....
        addEvent($title,$desc,$locat,$from,$until,$calendar);
      }
      if($day2 !="")
      {
            //... database lookup....
            addEvent($title,$desc,$locat,$from,$until,$calendar);
      }
      if($day3 !="")
      {
            //... database lookup....
            addEvent($title,$desc,$locat,$from,$until,$calendar);
      }
      //... until day 31 ...
  
  }
  </code></pre>
  
  <p>The event creation happens by function addEvent</p>
  
  <pre><code>function addEvent($title,$desc,$locat,$from,$until,$calendar)
  {
      $event = new Google_Event();
      $event-&gt;setSummary($title);
      $event-&gt;setDescription($desc);
      $event-&gt;setLocation($locat);
      $start = new Google_EventDateTime();
      $start-&gt;setDateTime($from);
      $event-&gt;setStart($start);
      $end = new Google_EventDateTime();
      $end-&gt;setDateTime($until);
      $event-&gt;setEnd($end);
      $createdEvent = $service-&gt;events-&gt;insert( $calendar, $event);
  }
  </code></pre>
  
  <p>To insert 1 event at a time is not a problem. But more than a few gives a white screen. How can I do a batch request to create up to 31 events? Any help is welcome. </p>