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 addEvent($calendarId, $summary, $description, $location, $dataTimeStart, $dataTimeEnd, $email, $accept) { $event = new Google_Service_Calendar_Event(); $event->setSummary($summary); $event->setLocation($location); $event->setDescription($description); $event->setVisibility('public'); $start = new Google_Service_Calendar_EventDateTime(); $start->setDateTime($dataTimeStart); $start->setTimeZone('America/Bogota'); $event->setStart($start); $end = new Google_Service_Calendar_EventDateTime(); $end->setDateTime($dataTimeEnd); $end->setTimeZone('America/Bogota'); $event->setEnd($end); $reminder1 = new Google_Service_Calendar_EventReminder(); $reminder1->setMethod('email'); $reminder1->setMinutes('55'); $reminder2 = new Google_Service_Calendar_EventReminder(); $reminder2->setMethod('email'); $reminder2->setMinutes('15'); $reminder = new Google_Service_Calendar_EventReminders(); $reminder->setUseDefault('false'); $reminder->setOverrides(array($reminder1, $reminder2)); $event->setReminders($reminder); //$event->setRecurrence(array('RRULE:FREQ=WEEKLY;UNTIL=20110701T170000Z')); $attendee1 = new Google_Service_Calendar_EventAttendee(); $attendee1->setEmail($email); if ($accept == "true") { $attendee1->setResponseStatus('accepted'); } $attendees = array($attendee1); $event->attendees = $attendees; $optParams = array('sendNotifications' => true, 'maxAttendees' => 1000); /*$creator = new Google_Service_Calendar_EventCreator(); $creator->setDisplayName("UNAD Calendar"); $creator->setEmail("*****@*****.**"); $event->setCreator($creator);*/ $nEvent = $this->service->events->insert($calendarId, $event, $optParams); return $nEvent; }
public function addEventAfterReservation($hours_array, $client_id, $resDate, $reservation_id, $reserve_type) { $hour_id = $hours_array['hours_id']; $choosen_places = $hours_array['choosen_places']; $direction_id = $hours_array['dirID']; $instructorCursor = Dispatcher::$mysqli->query("select * from instructor join instructor_has_hours " . "on instructor.`Person_id`=instructor_has_hours.instructor_id " . "where instructor_has_hours.hours_id={$hour_id}"); $instructorRow = $instructorCursor->fetch_assoc(); $defaultInstructorID = $instructorRow['Person_id']; $defaultInstructorCalendarID = $instructorRow['calendar_id']; $clientCursor = Dispatcher::$mysqli->query("select * from person where id={$client_id}"); $clientRow = $clientCursor->fetch_assoc(); $hourCursor = Dispatcher::$mysqli->query("select *, voucher_info.`name` as voucherName from hours_to_display " . "join voucher_info on hours_to_display.during_type=voucher_info.`type` " . "where hours_to_display.id={$hour_id}"); $hourRow = $hourCursor->fetch_assoc(); $event = new Google_Service_Calendar_Event(); $event->setSummary($choosen_places . " " . $hourRow['voucherName']); $event->setLocation('Saska, Praha 1'); $start = new Google_Service_Calendar_EventDateTime(); $start->setDateTime($resDate . 'T' . $hourRow['hour_from'] . ':00.000+02:00'); $start->setTimeZone('Europe/Prague'); $event->setStart($start); $end = new Google_Service_Calendar_EventDateTime(); $end->setDateTime($resDate . 'T' . $hourRow['hour_to'] . ':00.000+02:00'); $end->setTimeZone('Europe/Prague'); $event->setEnd($end); $event->description = $clientRow['name'] . "\n" . $clientRow['email'] . "\n" . $clientRow['telefone'] . "\n" . $choosen_places . "\n\n"; try { $new_event = $this->google_api_service->events->insert($defaultInstructorCalendarID, $event); $new_event_id = $new_event->getId(); Dispatcher::$mysqli->query("insert into event(clndr_event_id, `instructor_Person_id`, hours_id, date, has_changes) " . "values ('{$new_event_id}', '{$defaultInstructorID}', '{$hour_id}', '{$resDate}', 0)"); Dispatcher::$mysqli->query("insert into reservation_has_hours (reservation_id, `Person_id`, hours_id, " . "directions_en_id, " . "choosen_places, " . "date, reserve_type, event_clndr_event_id) " . "values ({$reservation_id}, {$client_id}, {$hour_id}, '{$direction_id}', {$choosen_places}, '{$resDate}', '{$reserve_type}', '{$new_event_id}')"); } catch (Google_Service_Exception $e) { echo '<pre>'; print_r($e); syslog(LOG_ERR, $e->getMessage()); } print_r(Dispatcher::$mysqli->error); }
/** * Creates a simple dummy event with a duration of 1 hour * @param string $calendar_id calendar ID * @param int $date_from_ts Unix TS, from date * @param string $name event name * @return error code */ public function createDummyEvent($calendar_id, $date_from_ts, $name) { $init_res = $this->initService(); if ($init_res != self::NO_ERRORS) { return array($init_res, null); } $date_to_ts = $date_from_ts + 3600; $location = 'Elsewhere'; $event = new Google_Service_Calendar_Event(); $event->setSummary($name); $event->setLocation($location); $start = new Google_Service_Calendar_EventDateTime(); $start->setDateTime(date('c', $date_from_ts)); $event->setStart($start); $end = new Google_Service_Calendar_EventDateTime(); $end->setDateTime(date('c', $date_to_ts)); $event->setEnd($end); try { $createdEvent = $this->service->events->insert($calendar_id, $event); return self::NO_ERRORS; } catch (Exception $e) { return self::EVENT_CREATION_ERROR; } return $createdEvent; }
public function addEvent($recordid, $Data, $tzOffset) { set_include_path($this->root_directory . "modules/Calendar4You/"); $startDate = $Data["date_start"]; $endDate = $Data["due_date"]; global $default_timezone; $startTime = $Data["time_start"]; $endTime = $Data["time_end"]; $event = new Google_Service_Calendar_Event(); $event->setSummary(trim($Data["subject"])); $event->setDescription($Data["description"]); $event->setLocation(trim($Data["location"])); $start = new Google_Service_Calendar_EventDateTime(); if (strlen($startTime) > 6) { $start->setDateTime($startDate . 'T' . $this->removeLastColon($startTime) . ':00.000'); } else { $start->setDateTime($startDate . 'T' . $this->removeLastColon($startTime) . ':00:00.000'); } $start->setTimeZone("{$default_timezone}"); $event->setStart($start); $end = new Google_Service_Calendar_EventDateTime(); if (strlen($endTime) > 6) { $end->setDateTime($endDate . 'T' . $this->removeLastColon($endTime) . ':00.000'); } else { $end->setDateTime($endDate . 'T' . $this->removeLastColon($endTime) . ':00:00.000'); } $end->setTimeZone("{$default_timezone}"); $event->setEnd($end); $SendEventNotifications = new Google_Service_Calendar_EventReminders(); //$SendEventNotifications->setValue(true); $event->setReminders($SendEventNotifications); $whos = $this->getInvitedUsersEmails($event, $recordid); if (count($whos) > 0) { $event->attendees = $whos; } // $appCallUri = ""; // // foreach ($this->gListFeed as $calendar) { // if ($calendar->id == $this->selected_calendar) $appCallUri = $calendar->content->src; // } try { $createdEvent = $this->gService->events->insert($this->selected_calendar, $event); $eventid = urldecode($createdEvent->getId()); } catch (Exception $e) { $status = null; } set_include_path($this->root_directory); return $eventid; }
/** * Creates a new google calendar event and returns * the resulting event inside an Event object. * * @param Event $event * * @return Event */ public function createEvent(Event $event) { $this->setCalendarId($event->calendar_id); /* * Create new google event object */ $googleEvent = new \Google_Service_Calendar_Event(); /* * Set Details */ $googleEvent->setSummary($event->title); $googleEvent->setDescription($event->description); $googleEvent->setLocation($event->location); /* * Set Start Date */ $start = $this->createDateTime($event->start, $event->timeZone, $event->all_day); $googleEvent->setStart($start); /* * Set End Date */ $end = $this->createDateTime($event->end, $event->timeZone, $event->all_day); $googleEvent->setEnd($end); /* * Set Recurrence Rule, make sure it's not empty */ if ($event->rrule) { $googleEvent->setRecurrence([$event->rrule]); } /* * Create the event */ $newGoogleEvent = $this->service->events->insert($this->calendarId, $googleEvent); return $this->createEventObject($newGoogleEvent); }
/** * 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(); } }
public function CUST_customercalendercreation1($calPrimary,$custid,$startdate,$startdate_starttime,$startdate_endtime,$enddate,$enddate_starttime,$enddate_endtime,$firstname,$lastname,$mobile,$intmobile,$office,$customermailid,$unit,$roomtype,$unitrmtype) { try{ $calId=$this->GetEICalendarId(); $initialsdate=$startdate; $initialedate=$enddate; $calendername= $firstname.' '.$lastname; $contactno=""; $contactaddr=""; if($mobile!=null) {$contactno=$mobile;} else if($intmobile!=null) {$contactno=$intmobile;} else if($office!=null) {$contactno=$office;} if($contactno!=null && $contactno!="") { $contactaddr=$custid." "."EMAIL :".$customermailid.",CONTACT NO :".$contactno; } else { $contactaddr=$custid." "."EMAIL :".$customermailid; } if($unitrmtype!="") { $details =$unit. " " . $calendername . " " .$unitrmtype." ". "CHECKIN"; } else { $details =$unit. " " . $calendername . " " . "CHECKIN"; } $details1 =$unit. " " .$roomtype ; if($initialsdate!="") { $event = new Google_Service_Calendar_Event(); $startevents=$this->CalenderTime_Convertion($startdate, $startdate_starttime, $startdate_endtime); $event->setStart($startevents[0]); $event->setEnd($startevents[1]); $event->setDescription($contactaddr); $event->setLocation($details1); $event->setSummary($details); $createdEvent = $calPrimary->events->insert($calId, $event); // to create a event } $endevents=$this->CalenderTime_Convertion($enddate,$enddate_starttime,$enddate_endtime); $detailsend =$unit. " " . $calendername . " " . "CHECKOUT"; $detailsend1 =$unit. " " .$roomtype ; if($initialedate!="") { $event = new Google_Service_Calendar_Event(); $event->setStart($endevents[0]); $event->setEnd($endevents[1]); $event->setDescription($contactaddr); $event->setLocation($detailsend1); $event->setSummary($detailsend); $createdEvent = $calPrimary->events->insert($calId, $event); // to create a event } return 1; } catch(Exception $e){ return $e->getMessage(); } }
public function CUST_customercalendercreation_StartDate($servicedoc,$calId,$calPrimary,$calevents,$custid,$firstname,$lastname,$mobile,$intmobile,$office,$customermailid,$unit,$unitrmtype) { try{ $folderIdCustomer=$this->Mdl_eilib_calender->getcustomerfileid($servicedoc,$custid); for($k=0;$k<count($calevents);$k++) { $attachments=[]; $Events=explode(',',$calevents[$k]); if($Events[5]=="CHECKIN"){ for($j=0;$j<count($folderIdCustomer)&&count($folderIdCustomer)>0;$j++){ $servicedoc= $this->Mdl_eilib_common_function->get_service_document(); $file = $servicedoc->files->get($folderIdCustomer[$j]); $attachments[]= array( 'fileUrl' => $file->alternateLink, 'mimeType' => $file->mimeType, 'title' => $file->title );}} $initialsdate = $Events[2]; $calendername = $firstname . ' ' . $lastname; $contactno = ""; $contactaddr = ""; if ($mobile != null) { $contactno = $mobile; } else if ($intmobile != null) { $contactno = $intmobile; } else if ($office != null) { $contactno = $office; } if ($contactno != null && $contactno != "") { $contactaddr = $custid . " " . "EMAIL :" . $customermailid . ",CONTACT NO :" . $contactno; } else { $contactaddr = $custid . " " . "EMAIL :" . $customermailid; } if ($Events[1] != "") { $details = $Events[0] . " " . $calendername . " " . $Events[1] . " " . $Events[5]; } else { $details = $Events[0] . " " . $calendername . " " . $Events[5]; } $details1 = $Events[0] . " " . $Events[1]; if ($initialsdate != "") { $event = new Google_Service_Calendar_Event(); $startevents = $this->CalenderTime_Convertion($Events[2], $Events[3], $Events[4]); $event->setStart($startevents[0]); $event->setEnd($startevents[1]); $event->setDescription($contactaddr); $event->setLocation($details1); $event->setSummary($details); if(count($folderIdCustomer)>0 && $Events[5]=="CHECKIN") { $event->setAttachments($attachments); $createdEvent = $calPrimary->events->insert($calId, $event,array('supportsAttachments' => TRUE)); // to create a event }else{ $createdEvent = $calPrimary->events->insert($calId, $event); } } } return 1; } catch(Exception $e){ return $e->getMessage(); } }
$value = array(); $propertiesToCopy = array("city", "date", "name", "email", "phone", "address", "comments"); $value["timestamp"] = date("n/j/Y H:i:s"); foreach ($propertiesToCopy as $property) { $value[$property] = trim($_REQUEST[$property]); } $registrationFeed->insert($value); $event = new Google_Service_Calendar_Event(); $name = $_REQUEST["name"]; $address = $_REQUEST["address"]; $email = $_REQUEST["email"]; $date = $_REQUEST["date"]; $comments = $_REQUEST["comments"]; $phone = $_REQUEST["phone"]; $event->setSummary("SSBCSJ Birthday Bhajan - Residence of {$name}"); $event->setLocation($address); $description = <<<EOD Format: 3 OMs 3 Gayatris 108 Names of Sathya Sai 9 Bhajans Multi Faith Chants 1 chapter reading of Tapovanam Aarti EOD; if (!empty($comments)) { $description .= "\nPhone: \n{$phone}\n\n"; }
if ($event["title"] == $data["title"] && $event["start"] == $data["start"] && $event["end"] == $data["end"]) { $exist_check = true; # 判斷成立 break; } } // 若 event 已存在的話,跳過進行下一個迴圈 if ($exist_check) { echo $data["title"] . "事件已存在<br>\n"; continue; } // 將 event 寫入 calendar 內 $event = new Google_Service_Calendar_Event(); $event->setSummary($data["title"]); // 事件標題 $event->setLocation($data["where"]); // 事件地點 $event->setDescription($data["desc"]); // 備註 $start = new Google_Service_Calendar_EventDateTime(); $start->setDateTime($data["start"]); $event->setStart($start); // 事件起始時間 $end = new Google_Service_Calendar_EventDateTime(); $end->setDateTime($data["end"]); $event->setEnd($end); // 事件結束時間 $createdEvent = $service->events->insert($calendar_id, $event); // 將事件寫入 calendar echo "Event " . $createdEvent->getId() . " created.<br>\n"; }
public function onRaidCreate($aRaidId) { if ($this->authenticate()) { // Query the given raid, make sure we include canceled and closed // raids $Parameters = array('raid' => $aRaidId, 'canceled' => true, 'closed' => true); $RaidResult = Api::queryRaid($Parameters); if (count($RaidResult) > 0) { // As we specified a specific raid id, we are only // interested in the first (and only) raid. // Cache and set UTC timezone just to be sure. $Raid = $RaidResult[0]; $LocationName = $this->mLocations[$Raid['LocationId']]; $Url = getBaseURL() . 'index.php#raid,' . $aRaidId; $Timezone = date_default_timezone_get(); try { date_default_timezone_set('UTC'); $Start = new Google_Service_Calendar_EventDateTime(); $Start->setDateTime(date($this->mDateFormat, intval($Raid['Start']))); $Start->setTimeZone('UTC'); $End = new Google_Service_Calendar_EventDateTime(); $End->setDateTime(date($this->mDateFormat, intval($Raid['End']))); $End->setTimeZone('UTC'); $Properties = new Google_Service_Calendar_EventExtendedProperties(); $Properties->setShared(array('RaidId' => $aRaidId)); $Source = new Google_Service_Calendar_EventSource(); $Source->setTitle('Raidplaner link'); $Source->setUrl($Url); $Event = new Google_Service_Calendar_Event(); $Event->setSummary($LocationName . ' (' . $Raid['Size'] . ')'); $Event->setLocation($LocationName); $Event->setDescription($Raid['Description']); $Event->setOriginalStartTime($Start); $Event->setStart($Start); $Event->setEnd($End); $Event->setExtendedProperties($Properties); $Event->setSource($Source); $this->mCalService->events->insert(GOOGLE_CAL_ID, $Event); } catch (Exception $Ex) { $Out = Out::getInstance(); $Out->pushError($Ex->getMessage()); } date_default_timezone_set($Timezone); } } }
public function createEvent($calendarID, array $eventData) { $event = new Google_Service_Calendar_Event(); $event->setSummary($eventData['summary']); $event->setLocation($eventData['location']); $event->setDescription($eventData['description']); $start = new Google_Service_Calendar_EventDateTime(); //$start->setDateTime('2014-9-30T10:00:00.000-05:00'); if (!isset($eventData['startDatetime'])) { $start->setDateTime($eventData['startDate'] . 'T' . $eventData['startTime']); } else { $start->setDateTime($eventData['startDateTime']); } $event->setStart($start); $end = new Google_Service_Calendar_EventDateTime(); //$end->setDateTime('2014-9-30T10:25:00.000-05:00'); if (!isset($eventData['endDateTime'])) { $end->setDateTime($eventData['endDate'] . 'T' . $eventData['endTime']); } else { $end->setDateTime($eventData['startDateTime']); } $event->setEnd($end); $createdEvent = $this->service->events->insert($calendarID, $event); return $createdEvent->getID(); }
exit(0); } $authCode = $_GET['code']; // Exchange authorization code for an access token. $accessToken = $client->authenticate($authCode); $_SESSION["googleauth"] = $accessToken; header("Location: calendar.php"); exit(0); } // Get the API client and construct the service object. $client = getClient(); $service = new Google_Service_Calendar($client); $event = new Google_Service_Calendar_Event(); $event->setSummary($_SESSION['event']['Summary']); $event->setDescription($_SESSION['event']['Description']); $event->setLocation($_SESSION['event']['Location']); $start = new Google_Service_Calendar_EventDateTime(); $start->setDateTime($_SESSION['event']['STime']); $event->setStart($start); $end = new Google_Service_Calendar_EventDateTime(); $end->setDateTime($_SESSION['event']['ETime']); $event->setEnd($end); $event->attendees = $_SESSION['event']['GrMem']; $calendarId = 'primary'; $event = $service->events->insert($calendarId, $event); $groupID = $_SESSION["event"]["gID"]; $_SESSION["event"] = 'Event created: ' . '<a href = "' . $event->htmlLink . '">' . $_SESSION["event"]["Summary"] . '</a>'; header("Location: group.php?id=" . urlencode($groupID)); ?>
<div class="col-lg-12"> <div class="ibox-content"> <br /> <?php if (isset($authUrl)) { echo "<a class='login' href='" . $authUrl . "'>Connect Me!</a>"; } else { echo <<<END <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>