With the new api v3 format you need to modify your code to this:
$calendarid = 'my calendar id';
$cal = new *Google_*CalendarService($client);
$event = new *Google_*Event();
$event->setSummary('My Event Name');
$start = new *Google_*EventDateTime();
$start->setDateTime('2012-04-04*T*10:00:00.000+12:00');
$start->setTimeZone('Pacific/Auckland');
$event->setStart($start);
$end = new *Google_*EventDateTime();
$end->setDateTime('2011-04-18*T*11:00:00.000+12:00');
$end->setTimeZone('Pacific/Auckland');
$event->setEnd($end);
$createdEvent = $cal->events->insert($calendarid, $event);
So a prefix of "Google_" needs to be added to each 'new function', and
don't forget to add the correct Date & Time formatting.
for date and time you can do either:
yyyy-mm-ddThh:mm:ss.000(+/1)hh:mm
or
yy-mm-ddThh:mm:ss(+/-)hh:mm
I have got a different error at the moment :/
On Monday, April 16, 2012 12:20:06 PM UTC+1, Harvey Kane wrote:
>
> Hi All,
>
> I'm having a spot of bother migrating an app to the new v3 Google
> calendar API. The documentation available for google-api-php-client
> seems rather minimal, so I wonder if someone can spot an issue with my
> code below...
>
> I have the app oauth authenticating, and I can get information out of
> the calendar using listEvents calls etc. What I can't do is insert a new
> event.
>
> $calendarid = 'my calendar id';
> $cal = new apiCalendarService($client);
> $event = new Event();
> $event->setSummary('My Event Name');
> $start = new EventDateTime();
> $start->setDateTime('2012-04-04 10:00:00.000+12:00');
> $start->setTimeZone('Pacific/Auckland');
> $event->setStart($start);
> $end = new EventDateTime();
> $end->setDateTime('2011-04-18 11:00:00.000+12:00');
> $end->setTimeZone('Pacific/Auckland');
> $event->setEnd($end);
> $createdEvent = $cal->events->insert($calendarid, $event);
>
> This generates a generic "400 bad request" error with no additional info
> about what the problem might be.
>
> Is anyone able to let me know what might be wrong with my code above, or
> let me know how to go about debugging this "bad request"error? I'd quite
> like to keep using the google-api-php-client if I can, but there seems
> to be a lot more documentation available if you are crafting the
> requests manually so this may be the better way to go. I'd wecome advice
> on that too.
>
> Thanks,
>
> Harvey.
>
> --
> Harvey Kane
>
> Phone:
> - Auckland: +64 9 950 4133
> - Wanaka: +64 3 746 8133
> - Mobile: +64 21 811 951
>
> Email: [email protected] <javascript:>
> If you need to contact me urgently, please read my email policy
> www.ragepank.com/email/
>
>
--
--
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]
---
You received this message because you are subscribed to the Google Groups "NZ
PHP Users Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.