Hey everyone, I'm fiddling with Google Calendar API, trying to make a
site where you as a member can join events.
My problem is to create an event from this site. The user is writing
all the values in a form which is being sent to a page that puts these
values into this:
<?php
session_start();
require_once "src/apiClient.php";
require_once "src/contrib/apiCalendarService.php";
$apiClient = new apiClient();
$apiClient->setUseObjects(true);
$service = new apiCalendarService($apiClient);
if (isset($_SESSION['oauth_access_token'])) {
$apiClient->setAccessToken($_SESSION['oauth_access_token']);
} else {
$token = $apiClient->authenticate();
$_SESSION['oauth_access_token'] = $token;
}
$summary=$_GET["summary"];
$location=$_GET["location"];
$description=$_GET["description"];
$starttime=$_GET["start"];
$attendeename=$_GET["attendeename"];
$attendeeemail=$_GET["attendeeemail"];
$calid=$_GET["calid"];
/*
*/
?>
<html>
<head>
<title>Kalender</title>
</head>
<body>
<?php
echo $calid;
$event = new Event();
$event->setSummary($summary);
$event->setDescription($description);
$event->setLocation($location);
$organizer = new EventOrganizer();
$organizer ->setEmail($attendeeemail);
$event->setOrganizer($organizer);
$event->setLocation($location);
$start = new EventDateTime();
$start->setDateTime($starttime);
$event->setStart($start);
$end = new EventDateTime();
$end->setDate('2012-16-02');
$event->setEnd($end);
$attendee1 = new EventAttendee();
$attendee1->setEmail($attendeeemail);
$attendee1->setDisplayName($attendeename);
// ...
$attendees = array($attendee1,
// ...
);
$event->attendees = $attendees;
print_r('<pre>');
print_r($event);
print_r('</pre>');
$createEvent = $service->events->insert($calid, $event);
echo $createEvent->getId(); ?>
</body>
</html>
But when I do so, I get the following error:
Fatal error: Uncaught exception 'apiServiceException' with message
'Error calling POST
https://www.googleapis.com/calendar/v3/calendars/4u2l2652jno7n...@group.calendar.google.com/events?key=MYKEY:
(400) Bad Request' in /usr/home/anped7/public_html/kalender/src/io/
apiREST.php:86 Stack trace: #0 /usr/home/anped7/public_html/kalender/
src/io/apiREST.php(56):
apiREST::decodeHttpResponse(Object(apiHttpRequest)) #1 /public_html/
kalender/src/service/apiServiceResource.php(186):
apiREST::execute(Object(apiServiceRequest)) #2 /public_html/kalender/
src/contrib/apiCalendarService.php(493): apiServiceResource-
>__call('insert', Array) #3
/public_html/kalender/create_BE.php(68): EventsServiceResource-
>insert('4u2l2652jno7n8p...', Object(Event)) #4 {main} thrown in /usr/
home/anped7/public_html/kalender/src/io/apiREST.php on line 86
Can anyone please help me?
Sincerely, Anders