Cannot use object of type Event as array
<p>I'm trying to import an event into my Google Calendar account, however my code fails to import due to an error: <code>Cannot use object of type Event as array</code> this appears in line 2149 in my script which is located here:</p>

<pre><code>$exported_events = array();
foreach($events as $event_id =&gt; $event)
{
    $event = new Event();
    $event-&gt;setSummary($event-&gt;location);
    $event-&gt;setLocation($event-&gt;location);

    $start = new EventDateTime();
    $start-&gt;setDateTime($event['starts']); // Line 2149
    $event-&gt;setStart($start);

    $end = new EventDateTime();
    $end-&gt;setDateTime((object) $event['ends']);
    $event-&gt;setEnd($end);

    $attendees = array();
    foreach($event['people'] as $i =&gt; $person)
    {
        $attendee = new EventAttendee();
        $attendee-&gt;setEmail($person-&gt;email);

        $attendees[] = $attendee;

        $event-&gt;attendees = $attendees;
    }

    $createdEvent = $service-&gt;events-&gt;insert('primary', $event);

    $calendar_event_id = $createdEvent-&gt;getId();

    if(!is_null($calendar_event_id))
    {
        $exported_events[] = $event_id; 
    }
}
</code></pre>

<p>Now, as my <code>foreach</code> loop walks over the <code>$events</code> array, it threw an error with <code>$event['location']</code> so I changed it to <code>$event-&gt;location</code>, now it throws an error on line 2149 which is an array item (the array is printed below the page) and if I change it to <code>$event-&gt;starts</code> it will throw me this error: <code>Undefined property: Event::$starts</code> even if I put <code>(object) $event['starts']</code> it will still won't work.</p>

<p>How can I pass it to make it work? <code>var_dump($event['starts'])</code> returns as a string.</p>

<p>The array of per each <code>$event</code>:</p>

<pre><code>Array
(
    [location] =&gt; Some location in the US
    [starts] =&gt; 2012-03-13T10:00:00
    [ends] =&gt; 2012-03-13T14:00:00
    [people] =&gt; Array
        (
            [0] =&gt; Array
                (
                    [name] =&gt; Joan Uton
                    [email] =&gt; rnewkj@hotmail.co.uk
                )

            [1] =&gt; Array
                (
                    [name] =&gt; Jack Sparrow
                    [email] =&gt; potc@gmail.com
                )

            [2] =&gt; Array
                (
                    [name] =&gt; Barack Obama
                    [email] =&gt; barak@obama.com
                )

        )

)
</code></pre>
