Created
March 6, 2013 16:35
-
-
Save nhaskins/5100705 to your computer and use it in GitHub Desktop.
PHP function to generate Google Calendar 'add event' links
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this function returns a URL that when clicked, attempts to add a gcal event | |
function gcal_evt_href($data) | |
{ | |
//return a gcal href link for anchors | |
//encode the data in the array for url formatting | |
foreach($data as &$xx) | |
{ | |
$xx = urlencode($xx); | |
} | |
$href = 'https://www.google.com/calendar/render?action=TEMPLATE&text=' | |
.$data['event_name'].'&dates=' | |
.$data['datetime_start'].'/' | |
.$data['datetime_end'].'&details=' | |
.$data['description'].'&location=' | |
.$data['location_text'].'&trp=false&sprop=' | |
.$data['sprop_website'].'&sprop=name:' | |
.$data['sprop_name'].'&pli=1&sf=true&output=xml'; | |
return $href; | |
} //end gcal_event_button | |
//example data to feed to the function | |
$data = array( | |
'event_name' => 'event_name', | |
'datetime_start' => '20130221', //YYYYMMDD | |
'datetime_end' => '20130222', //YYYYMMDD | |
'location_text' => 'name and address is fine', | |
'description' => 'longer desc for the details', | |
'sprop_website' => 'http://organization.com', | |
'sprop_name' => 'organization name' | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment