Import events in Google JSON format

Asked

Viewed 549 times

5

I want to import events from a non-public server-side Google Calendar (PHP) in JSON format.

Since I only want to receive information and do not need to edit/create events I assume there is a way that does not need authentication.

I know it is possible via iCal to download a file with calendar data with syntax: http://www.google.com/calendar/ical/{ID}/public/basic.ics, and that works in my case.

However I wanted to get the same but in JSON format and via PHP. Any suggestions?

  • Please could provide a {ID} so I can test?

  • @Pauloroberto: o link to iCal with a id in the url according to the syntax described above

2 answers

4


You just need to tell Google Calendar that you want a JSON, passing it as a parameter, and to rescue JSON, use the function file_get_contents() of PHP.

$json = file_get_contents('http://www.google.com/calendar/feeds/[email protected]/public/full?alt=json');  
echo $json;

Note that you are using the same {ID} used to fetch the ICS, but you are now ordering a JSON.

You can get specific and detailed information from Google Developers about using JSON to rescue information Here.

3

There are many components ready to extract calendar information in ICS format.

Try for example this class PHP iCal Parser. Note, I moderate this site, but I did not develop this class.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.