$client->setUseObjects(true);
$eventList->getItems();
foreach( $eventList['items'] as $event) {
//...
}
<?php
require_once 'Google_Client.php';//google-api-php-client/src/
require_once 'contrib/Google_CalendarService.php';
session_start();
$client = new Google_Client();
$client->setApplicationName("Simple Google Calendar Updater");
// Visit https://code.google.com/apis/console?api=calendar to generate your
// client id, client secret, and to register your redirect uri.
$client->setClientId('your client id');
$client->setClientSecret('your client secret');
$client->setRedirectUri('your redirec uri');
$client->setDeveloperKey('your api key');
$client->setUseObjects(true);
$service = new Google_CalendarService($client);
if (isset($_GET['logout'])) {
unset($_SESSION['token']);
}
if (isset($_GET['code'])) {
$client->authenticate($_GET['code']);
$_SESSION['token'] = $client->getAccessToken();
header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
}
if (isset($_SESSION['token'])) {
$client->setAccessToken($_SESSION['token']);
}
if ($client->getAccessToken()) {
echo '<!DOCTYPE HTML><html><body>' . "\n";
//Find the event
echo 'Looking for event with the Summary: "Work Meeting"' . '<BR>' . "\n";
$eventList = $service->events->listEvents('primary');
$items = $eventList->getItems();
$eventID = 'none';
foreach($items as $ev) {
$summary = $ev->getSummary();
if ($summary == "Work Meeting") {
$eventID = $ev->getId();
}
}
//Update the description
if ($eventID != 'none') {
$event = $service->events->get('primary', $eventID);
$event->setDescription('This is serious work');
$updatedEvent = $service->events->update('primary', $eventID, $event);
// Print the updated date.
echo 'The event was found and updated on: ' . $updatedEvent->getUpdated();
}
else {
echo 'Event not found!';
}
echo "</body></html>";
$_SESSION['token'] = $client->getAccessToken();
} else {
$authUrl = $client->createAuthUrl();
print "<a class='login' href='$authUrl'>Connect Me!</a>";
}
?>
Thanks for working for google for free.
--
You received this message because you are subscribed to the Google Groups "google-api-php-client" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-api-php-c...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.