public function registrarEvento() { require_once 'complements/Google/Client.php'; require_once 'complements/Google/Service/Calendar.php'; session_start(); $client = new Google_Client(); $client->setApplicationName("Google Calendar PHP Starter Application"); // Visit https://code.google.com/apis/console?api=calendar to generate your // client id, client secret, and to register your redirect uri. $client->setClientId('1027408579728-fomlujink6upq6e1j2fu7nb4tu1frqq7.apps.googleusercontent.com'); $client->setClientSecret('BTzww96MUByc_Ibsy2xX0asR'); $client->setRedirectUri('http://www.hostf5.com.br/f5admin/agenda/redirect'); $client->setDeveloperKey('AIzaSyB9AHH2apXJ7RJ25m5n2yLEMyhKOKA6sMU'); $client->setScopes(array('https://www.googleapis.com/auth/plus.me', 'https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/userinfo.profile', 'https://www.googleapis.com/auth/calendar', 'https://www.googleapis.com/auth/calendar.readonly')); $cal = new Google_Service_Calendar($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()) { $event = new Google_Service_Calendar_Event(); $event->setSummary($title); $event->setLocation($location); $start = new Google_Service_Calendar_EventDateTime(); $start->setTimeZone('America/Montreal'); $start->setDateTime($date . 'T' . $startTime . ':00.000-06:00'); $event->setStart($start); $end = new Google_Service_Calendar_EventDateTime(); $end->setTimeZone('America/Montreal'); $end->setDateTime($date . 'T' . $endTime . ':00.000-06:00'); $event->setEnd($end); $attendee1 = new Google_Service_Calendar_EventAttendee(); $attendee1->setEmail($email); $attendees = array($attendee1); $event->attendees = $attendees; $cal->events->insert($email, $event); $_SESSION['token'] = $client->getAccessToken(); } else { $authUrl = $client->createAuthUrl(); print "<a class='login' href='{$authUrl}'>Connect me!</a>"; } }
function setAttendees($calendarId, $eventId, $email, $accept) { $event = $this->service->events->get($calendarId, $eventId); $attendees = array(); foreach ($event->attendees as $key => $value) { $attendees[] = $value; } $attendee1 = new Google_Service_Calendar_EventAttendee(); $attendee1->setEmail($email); if ($accept == "true") { $attendee1->setResponseStatus('accepted'); } $attendees[] = $attendee1; $event->attendees = $attendees; $optParams = array('sendNotifications' => true, 'maxAttendees' => 1000); $updatedEvent = $this->service->events->update($calendarId, $event->getId(), $event, $optParams); return $updatedEvent->getUpdated(); }
private function getInvitedUsersEmails($GCalClass, $recordid) { $whos = array(); $sql = 'select vtiger_users.email1, inviteeid from vtiger_invitees left join vtiger_users on vtiger_invitees.inviteeid=vtiger_users.id where activityid=?'; $result = $this->db->pquery($sql, array($recordid)); $num_rows = $this->db->num_rows($result); if ($num_rows > 0) { for ($i = 0; $i < $num_rows; $i++) { //$userid=$this->db->query_result($result,$i,'inviteeid'); $googleEmail = $this->db->query_result($result, $i, 'email1'); $who = new Google_Service_Calendar_EventAttendee(); $who->setEmail($googleEmail); $whos[] = $who; } } return $whos; }
// //5 establishes eastern time // $start->setDateTime("2015-01-04T'T' . $hr . ':' . $min . ':00.000-05:00'); // $event->setStart($start); // $end = new Google_Service_Calendar_EventDateTime(); // $end->setDateTime($date . 'T' . $endhr . ':' . $endmin . ':00.000-05:00'); // $event->setEnd($end); $event->setSummary("hello"); $start = new Google_Service_Calendar_EventDateTime(); $start->setDateTime('2015-01-03T10:22:00.000-05:00'); $event->setStart($start); $end = new Google_Service_Calendar_EventDateTime(); $end->setDateTime('2015-01-05T10:25:00.000-05:00'); $event->setEnd($end); alert("hello"); $attendee1 = new Google_Service_Calendar_EventAttendee(); $attendee1->setEmail($email); $attendees = array($attendee1); $createdEvent = $service->events->insert('primary', $event); echo $createdEvent->getId(); alert("Hello2"); echo $date; echo $hr; echo $min; echo $eventTitle; echo $ampm; echo $endampm; echo $endhr; echo $endmin; } ?>
/** * The customerCreate method prepares data for Stripe_Customer::create and attempts to * create a customer. * * @param array $data The data passed directly to Stripe's API. * @return array $customer if success, string $error if failure. */ public function updateEvent($data) { $client = new Google_Client(); $client->setApplicationName("Plat"); $key = file_get_contents($this->googleApiKeyFile); // separate additional scopes with a comma $scopes = "https://www.googleapis.com/auth/calendar"; //$client->setScopes(array($scopes)); $cred = new Google_Auth_AssertionCredentials($this->googleEmailAddress, array($scopes), $key); $client->setAssertionCredentials($cred); if ($client->getAuth()->isAccessTokenExpired()) { $client->getAuth()->refreshTokenWithAssertion($cred); } $service = new Google_Service_Calendar($client); $event = new Google_Service_Calendar_Event(); //$event->setId($data['eventId']); $event->setSummary($data['eventSummary']); $event->setDescription($data['eventDescription']); $event->setLocation($data['eventLocation']); $start = new Google_Service_Calendar_EventDateTime(); $start->setDateTime($data['eventStartDate']); $start->setTimeZone($data['eventTimeZone']); $event->setStart($start); $end = new Google_Service_Calendar_EventDateTime(); $end->setDateTime($data['eventEndDate']); $end->setTimeZone($data['eventTimeZone']); $event->setEnd($end); $attendee1 = new Google_Service_Calendar_EventAttendee(); $attendee1->setEmail(Configure::read("ADMIN_ORDER_EVENT_EMAIL")); $attendees = array($attendee1); $event->attendees = $attendees; $event->setSequence(Configure::read("GOOGLE_CALENDAR_API_SEQUENCE")); $calendar_id = Configure::read("GOOGLE_CALENDAR_ID"); try { $updateEvent = $service->events->update($calendar_id, $data['eventId'], $event); // $new_event_status = $updateEvent->getStatus(); return $new_event_status; } catch (Google_Service_Exception $e) { syslog(LOG_ERR, $e->getMessage()); return $e->getMessage(); } }
/** * Add an Event to the specified calendar * * @param string $calendarId Calendar's ID in which you want to insert your event * @param datetime $eventStart Event's start date * @param datetime $eventEnd Event's end date * @param string $eventSummary Event's title * @param string $eventDescription Event's description where you should put all your informations * @param array $eventAttendee Event's attendees : to use the invitation system you should add the calendar owner to the attendees * @param array $optionalParams Optional params * * @return object Event */ public function addEvent($calendarId, $eventStart, $eventEnd, $eventSummary, $eventDescription, $eventAttendee, $optionalParams = []) { // Your new GoogleEvent object $event = new \Google_Service_Calendar_Event(); // Set the title $event->setSummary($eventSummary); // Set and format the start date $formattedStart = $eventStart->format(\DateTime::RFC3339); $formattedEnd = $eventEnd->format(\DateTime::RFC3339); $start = new \Google_Service_Calendar_EventDateTime(); $start->setDateTime($formattedStart); $event->setStart($start); $end = new \Google_Service_Calendar_EventDateTime(); $end->setDateTime($formattedEnd); $event->setEnd($end); // Default status for newly created event $event->setStatus('tentative'); // Set event's description $event->setDescription($eventDescription); // Attendees - permit to manage the event's status $attendee = new \Google_Service_Calendar_EventAttendee(); $attendee->setEmail($eventAttendee); $event->attendees = [$attendee]; // Event insert return $this->getCalendarService()->events->insert($calendarId, $event, $optionalParams); }
<iframe src="https://www.google.com/calendar/embed?height=600&wkst=1&bgcolor=%23FFFFFF&src=jeffjtd745%40gmail.com&color=%232952A3&ctz=America%2FNew_York" style=" border-width:0 " width="800" height="600" frameborder="0" scrolling="no"></iframe> END; } ?> <?php $event = new Google_Service_Calendar_Event(); $event->setSummary('Appointment'); $event->setLocation('Somewhere'); $start = new Google_Service_Calendar_EventDateTime(); $start->setDateTime('2011-06-03T10:00:00.000-07:00'); $event->setStart($start); $end = new Google_Service_Calendar_EventDateTime(); $end->setDateTime('2011-06-03T10:25:00.000-07:00'); $event->setEnd($end); $attendee1 = new Google_Service_Calendar_EventAttendee(); $attendee1->setEmail('*****@*****.**'); $attendees = array($attendee1); $createdEvent = $service->events->insert('primary', $event); echo $createdEvent->getId(); ?> </div> </div> </div> </div> <div class="footer"> <div class="pull-right"> 10GB of <strong>250GB</strong> Free. </div> <div> <strong>Copyright</strong> Example Company © 2014-2015