PHP Classes

PHP Google Calendar Add Event: Create 'Add to my google calendar' link for a page

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 195 All time: 8,533 This week: 78Up
Version License PHP version Categories
gcalendar 1.0.0Freely Distributable5HTML, PHP 5, Time and Date
Description 

Author

This package can be used to create 'Add to my google calendar' link for a page.

It can take several parameters to configure the details of a given event, so it can generate HTML for a link on a page that when the user clicks on it will be added to his Google Calendar.

Currently it takes parameters to define event details like:

- Event name
- Event start date and time zone
- Event duration
- Event location
- Event description
- Event guest email addresses

Innovation Award
PHP Programming Innovation award winner
December 2020
Winner


Prize: One official elePHPant Plush Mascott
Google Calendar is a popular task scheduling application used by many people.

This package provides a simple way to add a scheduled task to Google Calendar by generating a link with all the parameters of the task.

So when the user clicks on that link, the browser goes to a page of Google Calendar to add the task to his calendar.

This way it becomes simple for a site to add tasks to other people calendars on Google Calendar.

Manuel Lemos
Picture of Stefan Kientzler
  Performance   Level  
Name: Stefan Kientzler is available for providing paid consulting. Contact Stefan Kientzler .
Classes: 19 packages by
Country: Germany Germany
Age: 57
All time rank: 71946 in Germany Germany
Week rank: 20 Up2 in Germany Germany Up
Innovation award
Innovation award
Nominee: 11x

Winner: 6x

Example

<?php
require_once 'autoloader.php';

use
SKien\GCalendar\GCalAddEventLink;

$oLink = new GCalAddEventLink();

$oLink->setSubject('Zoom meeting at christmas day');
$oLink->setStart('2020-12-24 13:00');
$oLink->setDuration('PT1H'); // 1 hour
$oLink->setTimezone('America/New_York');
$oLink->setDetails(
   
'We just want to meet us via zoom cause we are not allowed to ' . PHP_EOL .
   
'meet us at the christmas market :-(' . PHP_EOL . PHP_EOL .
   
'And this is just a check whether the usual problems caused by' . PHP_EOL .
   
'German umlauts are correctly intercepted: ä, ö, ü, Ä, Ö, Ü, ß ...'
);
$oLink->setLocation('Homeoffice');
$oLink->addGuest('guest1@example.com');
$oLink->addGuest('guest2@example.com');

echo
'<h1>Example to add event to google calendar</h1>' . PHP_EOL;
echo
'<a target="_blank" href="' . $oLink->getHREF() . '">Add to google calendar</a>' . PHP_EOL;


Details

Create 'Add to my google calendar' Link to your Homepage

Latest Stable Version License Donate Minimum PHP Version Scrutinizer Code Quality

Overview

This class can generate the HREF value to provide a Add to my google calendar link to your page.

Following Data for the event to create is supported: - Subject

- `setSubject()`  
  • Start Date/Time - `setStart()`
  • End Date/Time or Duration(if not set, default duration of 30 min is used) - `setEnd()` or `setDuration()`
  • Timezone (if not set, system settings used) - `setTimezone()`
  • All day Event - `setTimezone()`
  • Detailed Description (optional) - `setDetails()`
  • Location - `setLocation()`
  • Additional Guest(s) - `addGuest()`

Usage

  1. Create an instance of the GCalAddEventLink class
  2. Set the required information for the event to be generated
  3. Pass the generated HREF to an <a> element on your page

See AddEventExample.php

Logging

This package can use any PSR-3 compliant logger. The logger is initialized with a NullLogger-object by default. The logger of your choice have to be passed to the constructor of the GCalAddEventLink class.

If you are not working with a PSR-3 compatible logger so far, this is a good opportunity to deal with this recommendation and may work with it in the future.

There are several more or less extensive PSR-3 packages available on the Internet.

You can also take a look at the 'XLogger' package and the associated blog 'PSR-3 logging in a PHP application' as an introduction to this topic.

History

2020-12-15 Version 1.00

* initial Version


  Files folder image Files (14)  
File Role Description
Files folder imagePsr (1 directory)
Files folder imageSKien (1 directory)
Accessible without login Plain text file AddEventExample.php Example Example script
Accessible without login Plain text file autoloader.php Aux. Auxiliary script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpstan.neon Data Auxiliary data
Accessible without login Plain text file readme.md Doc. Documentation

  Files folder image Files (14)  /  Psr  
File Role Description
Files folder imageLog (8 files)

  Files folder image Files (14)  /  Psr  /  Log  
File Role Description
  Plain text file AbstractLogger.php Class Class source
  Plain text file InvalidArgumentException.php Class Class source
  Plain text file LoggerAwareInterface.php Class Class source
  Plain text file LoggerAwareTrait.php Class Class source
  Plain text file LoggerInterface.php Class Class source
  Plain text file LoggerTrait.php Class Class source
  Plain text file LogLevel.php Class Class source
  Plain text file NullLogger.php Class Class source

  Files folder image Files (14)  /  SKien  
File Role Description
Files folder imageGCalendar (1 file)

  Files folder image Files (14)  /  SKien  /  GCalendar  
File Role Description
  Plain text file GCalAddEventLink.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:195
This week:0
All time:8,533
This week:78Up
User Comments (1)
Very easy and functional.
3 years ago (martin butt)
80%StarStarStarStarStar