So in my last post on this topic I had set-up the htaccess file that will automatically redirect every URI request in that folder to a generic PHP file. This file will then grab the page name and then present a ICS file back to the client that has been customised with the students timetable.

So lets get straight into it.

First I want to grab just the page name so I can use it to look up the student record.

Ok. Now that is out of the way, we take that key and look up the student information from it.

Great. Now I know who we are looking at. Next step is to start outputting the ICS file to the client.

There are a few more items that you can place into the setup to help clients etc along. There is a heap of information about the standard at http://www.kanzaki.com/docs/ical/

Next step is to get all of the calendar items for the student. I am not going to go into depth on this query as it would be HUGELY different for each site. Once you have all of these items, we can start to output them to the client via a loop or similar.

and finally, close off the calendar

Next thing to do was to test it out to see if it was working correctly. So I pointed my browser over to the test address of http://demo.mybookit.com.au/calendar/QRikK8NkVVrkG5gtwGE8pKNXB.ics which outputted the ics file.

It all looked good and appeared to be correct. To be sure I was on the right track I ran the code past a ICS validator at http://icalvalid.cloudapp.net/ which gave me a perfect score.

Wow, following the standard sure does work out well.

Wow, following the standard sure does work out well.

The last test was to ensure that it updated correctly, so I moved one of Student 7’s classes from 3:00pm friday to 10:00am Tuesday. I then let the calendar update and the appointment had moved correctly.

So that is all there is to it. The final steps is to add it to the actual site so people can click on it to add it to their devices. It should be noted that iPhones work really well with this. You click on the link and it imports straight away. Unfortunately Android phones appear to need a third party app to get it working correctly. I will post more about that when I have had time to look into it completely.