public function test() { $this->client = new Google_Client(); $this->client->setApplicationName('Hangout Schedule'); $this->client->setClientId('191072902750-o87q963i0t05pkb96mvfusb3gsutpsmv.apps.googleusercontent.com'); $this->client->setClientSecret('KfLw32e9BM9GxfaGjUAOL3I2'); $this->client->setRedirectUri('http://local.youniqueproducts.com/api/oauth2/responseFrom/Google'); $this->client->setScopes("https://www.googleapis.com/auth/calendar"); $service = new Google_Service_Calendar($this->client); $this->getAccessToken(); $this->setTestData(); $event = new Google_Event(); $event->setSummary($this->testData['summary']); $event->setLocation('Younique Virtual Party!'); $start = new Google_EventDateTime(); $start->setDateTime($this->testData['start']['dateTime'] . '.000-00:00'); $event->setStart($start); $end = new Google_EventDateTime(); $end->setDateTime($this->testData['end']['dateTime'] . '.000-00:00'); $event->setEnd($end); // $attendee1 = new Google_EventAttendee(); // $attendee1->setEmail('*****@*****.**'); // $attendees = array($attendee1); // $event->attendees = $attendees; $createdEvent = $service->events->insert('primary', $event); var_dump($createdEvent); }
public function AddActivitat($id, $timestamp_inici, $timestamp_fi, $organitzador, $email, $titol, $link, $location, $summary, $description, $calendarid, $color_id, $idS) { date_default_timezone_set('Europe/Madrid'); //echo date(DateTime::RFC3339,mktime(17,30,00,1,14,2013)); $E = new Google_Event(); $O = new Google_EventOrganizer(); $O->setDisplayName($titol); $O->setEmail($email); $E->setOrganizer($O); $E->setSummary($titol); $E->setHtmlLink($link); $E->setLocation($location); $E->setDescription(html_entity_decode(strip_tags($description))); $start = new Google_EventDateTime(); $start->setDateTime(date(DateTime::RFC3339, $timestamp_inici)); $E->setStart($start); $end = new Google_EventDateTime(); $end->setDateTime(date(DateTime::RFC3339, $timestamp_fi)); $E->setEnd($end); $E->setColorId($color_id); $this->cal->events->insert(OptionsPeer::getString('GOOGLE_CALENDAR_ID', $idS), $E); }
/** * Add an appointment record to its providers Google Calendar account. * * This method checks whether the appointment's provider has enabled the Google * Sync utility of Easy!Appointments and the stored access token is still valid. * If yes, the selected appointment record is going to be added to the Google * Calendar account. * * @param array $appointment Contains the appointment record data. * @param array $provider Contains the provider record data. * @param array $service Contains the service record data. * @param array $customer Contains the customer recod data. * @parma array $company_settings Contains some company settings that are used * by this method. By the time the following values must be in the array: * 'company_name'. * @return Google_Event Returns the Google_Event class object. */ public function add_appointment($appointment, $provider, $service, $customer, $company_settings) { $this->CI->load->helper('general'); $event = new Google_Event(); $event->setSummary($service != NULL ? $service['name'] : 'Unavailable'); $event->setLocation($company_settings['company_name']); $start = new Google_EventDateTime(); $start->setDateTime(date3339(strtotime($appointment['start_datetime']))); $event->setStart($start); $end = new Google_EventDateTime(); $end->setDateTime(date3339(strtotime($appointment['end_datetime']))); $event->setEnd($end); $event->attendees = array(); $event_provider = new Google_EventAttendee(); $event_provider->setDisplayName($provider['first_name'] . ' ' . $provider['last_name']); $event_provider->setEmail($provider['email']); $event->attendees[] = $event_provider; if ($customer != NULL) { $event_customer = new Google_EventAttendee(); $event_customer->setDisplayName($customer['first_name'] . ' ' . $customer['last_name']); $event_customer->setEmail($customer['email']); $event->attendees[] = $event_customer; } // Add the new event to the google calendar. $created_event = $this->service->events->insert($provider['settings']['google_calendar'], $event); return $created_event; }
function cloud_scrivi_calendar($evento_descr, $evento_start, $evento_durata = '+2 hours', $evento_location = '', $event_id = null) { $evento_descr = $evento_descr; $evento_start1 = strtotime($evento_start); $evento_end1 = strtotime($evento_start . $evento_durata); $evento_location = $evento_location; /*************** DA QUI IN GIU NON TOCCHEREI PIU NULLA... ******************/ $app_name = 'allarrembaggio'; $client_id = '1034795448812-gghclbbghnvnmotg6as7524fraeojfnh.apps.googleusercontent.com'; $email_address = '*****@*****.**'; $key_file = plugin_dir_path(__FILE__) . 'google-api-php-client/allarrembaggio-85318f0a4e9d.p12'; $calendar_id = '*****@*****.**'; $evento_start = gmdate('Y-m-d\\TH:i:s', $evento_start1); $evento_end = gmdate('Y-m-d\\TH:i:s', $evento_end1); require_once "google-api-php-client/src/Google_Client.php"; require_once "google-api-php-client/src/contrib/Google_CalendarService.php"; $client = new Google_Client(); $client->setUseObjects(true); $client->setApplicationName($app_name); $client->setClientId($client_id); $client->setAssertionCredentials(new Google_AssertionCredentials($email_address, array("https://www.googleapis.com/auth/calendar"), file_get_contents($key_file))); //setAssertionCredentials $service = new Google_CalendarService($client); $event = new Google_Event(); $event->setSummary($evento_descr); $event->setLocation($evento_location); $start = new Google_EventDateTime(); $start->setDateTime($evento_start); $start->setTimeZone('Europe/Rome'); $event->setStart($start); $end = new Google_EventDateTime(); $end->setDateTime($evento_end); $end->setTimeZone('Europe/Rome'); $event->setEnd($end); //--prima di crearlo, elimino eventuali eventi if ($event_id != null) { $service->events->delete($calendar_id, $event_id); } //--creo l'evento $new_event = null; try { $new_event = $service->events->insert($calendar_id, $event); $new_event_id = $new_event->getId(); } catch (Google_ServiceException $e) { syslog(LOG_ERR, $e->getMessage()); } $output = null; $output = $service->events->get($calendar_id, $new_event->getId()); $output = $output->getId(); return $output; }
$event = new Google_Event(); #Set Summary $event->setSummary(html_entity_decode($seevent->getTitle(), ENT_QUOTES, 'UTF-8')); #Set Description $sDescription = strip_tags(html_entity_decode($seevent->description, ENT_QUOTES, 'UTF-8')); $sEventUrl = $seevent->getHref(); $event->setDescription($sDescription); #Set Location $sLocation = html_entity_decode($seevent->location, ENT_QUOTES, 'UTF-8'); if ($seevent->address != '') { $sLocation .= ', ' . html_entity_decode($seevent->address, ENT_QUOTES, 'UTF-8'); } if ($seevent->city != '') { $sLocation .= ', ' . html_entity_decode($seevent->city, ENT_QUOTES, 'UTF-8'); } $event->setLocation($sLocation); $strStart = Engine_Api::_()->ynevent()->getDateStringForCalendar($seevent->starttime); $strEnd = Engine_Api::_()->ynevent()->getDateStringForCalendar($seevent->endtime); #Set Start time $start = new Google_EventDateTime(); $start->setDateTime($strStart); $event->setStart($start); #Set End time $end = new Google_EventDateTime(); $end->setDateTime($strEnd); $event->setEnd($end); #Get Calendar list $calendarList = $cal->calendarList->listCalendarList(); #Check main Calendar if (count($calendarList)) { foreach ($calendarList['items'] as $calendar) {
function saveToCalendar($gig, $calendartype = 'private') { // print_r($gig_details = getGigTextDescription($gig, 'calendar')); exit(); // return; //FIXME global $calendars; extract($calendars[$calendartype]); if ($calendartype == 'public' && !$gig['public_description']) { return; } $cal = getGoogleClient(); $event = new Google_Event(); $gig_details = ""; $title = $gig['title']; if ($calendartype == 'private') { if ($gig['type'] == 'gig') { $prefix = 'Proposed'; if ($gig['approved'] == 1) { $prefix = 'Gig'; } else { if ($gig['approved'] == -1) { $prefix = 'Declined'; } } $title = "{$prefix}: {$title}"; } else { if ($gig['tactical']) { $members = gigs_fetchMembers(); $title .= ": " . $members[$gig['tactical']]['name']; } } $gig_details = getGigTextDescription($gig, 'calendar'); if (!$gig[$start_field]) { $start_field = 'band_start'; } } else { $gig_details = $gig['public_description']; } $event->setSummary($title); $event->setLocation($gig['location']); $event->setStart(newDateTime($gig['date'], $gig[$start_field])); $event->setEnd(newDateTime($gig['date'], $gig[$end_field])); $event->setDescription($gig_details); $createdEvent = ''; try { if ($gig[$id_field]) { $event->setSequence(time()); $createdEvent = $cal->events->update($calendar_id, $gig[$id_field], $event); } else { $createdEvent = $cal->events->insert($calendar_id, $event); $google_gig_id = $createdEvent->getId(); dbwrite("update gigs set {$id_field} = '" . dbEscape($google_gig_id) . "' where gig_id = {$gig['gig_id']}"); } } catch (Exception $e) { //trigger_error('Error creating google calendar entry: '.$e->getMessage(), E_USER_ERROR); } if (!$createdEvent) { //trigger_error('Error creating google calendar entry', E_USER_ERROR); } }
/** * Execute the upload of the file to the calendar service * * @param string $sourcefile * @return boolean */ public static function newEvent($summary, $location, $description = null, $datestart = null, $dateend = null) { try { if (empty($datestart)) { $datestart = date('Y-m-d'); } if (empty($dateend)) { $dateend = date('Y-m-d'); } $calendar = Settings::findbyParam('calendar_calendarid'); if ($calendar) { $cal = self::$calendar; if (is_object($cal) && !empty($cal)) { $event = new Google_Event(); $event->setSummary($summary); // Event name $event->setLocation($location); // Event location $start = new Google_EventDateTime(); $start->setDate($datestart); $event->setStart($start); $end = new Google_EventDateTime(); $end->setDate($dateend); $event->setEnd($end); $event->setDescription($description); $createdEvent = $cal->events->insert($calendar, $event); Shineisp_Commons_Utilities::log("The Event has been created!", "plugin_calendar.log"); return true; } } return false; } catch (Exception $e) { return $e->getMessage(); } }