title: How to add an event to another persons calendar using google calendar api?
body: <p>i am trying to add a event to a particular person's calendar , 
  the person is decided based on html form the value is stored in send</p>
  
  <p>The mail is sent but event is not set.</p>
  
  <p>this is my php code..</p>
  
  <pre><code>&lt;?php
  require_once 'google-api-php-client-master/autoload.php';
  require_once 'google-api-php-client-master/src/Google/Service/Calendar.php';
  $client = new Google_Client();
  // OAuth2 client ID and secret can be found in the Google Developers Console.
  $client-&gt;setClientId('######.apps.googleusercontent.com');
  $client-&gt;setClientSecret('###');
  $client-&gt;setRedirectUri('https://www.example.com/oauth2callback');
  $client-&gt;addScope('https://www.googleapis.com/auth/calendar');
  
  $send = $_POST["to"];
  echo "Welcome $send successfully set an event in your calendar";
  if( $send == "abc")
  {
      $to = "abc@gmail.com";
      $subject = "Sample Mail Project";
      $txt = $_POST["txt"];
      $headers = "From: xyz@gmail.com" . "\r\n" ;
      mail($to,$subject,$txt,$headers);
      $event = new Google_Service_Calendar_EventDateTime();
      $event-&gt;setSummary('Appointment');
      $event-&gt;setLocation('VIZAG');
      $start = new Google_Service_Calendar_Event();
      $start-&gt;setDateTime('2014-12-19T06:00:00');
      $event-&gt;setStart($start);
      $start = new Google_Service_Calendar_Event();
      $end-&gt;setDateTime('2014-12-19T10:10:00');
      $event-&gt;setEnd($end);
      $attendee1 = new EventAttendee();
      $attendee1-&gt;setEmail('abc@gmail.com');
      // ...
      $attendees = array($attendee1
          // ...
      );
      $event-&gt;attendees = $attendees;
      $createdEvent = $service-&gt;events-&gt;insert('primary', $event);
      echo $createdEvent-&gt;getId();
  }
  </code></pre>