Outlook Calendar REST API
I’ve been thinking about useful, but non-existent, web services lately. What I want is a REST interface to my Outlook calendar (i.e. “the one I’m forced to use at work“) that serves up vCalendar data. (Actually vCalendar isn’t XML, but there looks to be an XML version. I would prefer that, as I could always transform XML to standard vCal using XSLT.) I will then take that data and write a nifty Dashboard widget to display my next appointment on my Macintosh.
I know there must be some way to do this. I’ve seen products that sync calendar data with Outlook, but the files I found on the Microsoft web site weren’t too helpful in getting me started. I couldn’t tell if I need use Windows to communicate with Exchange using some special protocol, or if I can do it from Linux using standards. Ah, Microsoft.
Comment by JHill on 25 May 2005:
If you have the web access for exchange available, you can use WebDAV to query the calendars that you have access to.
Comment by Adam Trachtenberg on 25 May 2005:
I do have web access. I will explore the WebDAV angle. Thanks!
Comment by AJ on 26 May 2005:
hey Adam,
You can also use Python to access your Outlook calendar, I wrote an app that extracted my calendar using Python a couple months ago:
http://cephas.net/blog/2004/09/17/sending_your_outlook_calendar_using_python.html
AJ
Comment by George Schlossnagle on 27 May 2005:
I did a similar thing with my iCal calendars, which I push to a DAV server. For syncing that with the salesforce SOAP API, I pull the files back over DAV, parse them in PHP, and use ext/soap to manage the SF syncing. Doing something similar and exposing them over REST instead of pushing them over SOAP would be easy.
Comment by Adam Trachtenberg on 27 May 2005:
Thanks to the good comments above, and after lots of digging around, I have managed to make a successful Outlook Calendar request from PHP using a hacked version of HTTP_Request.
I modified the package (hurray for open source) to include DAV SEARCH support (which technically isn’t official DAV yet, so it’s not even in the HTTP_DAV_Client package), and I was able to figure out all the authentication settings for my server, and search SQL syntax for pulling Calendar records. (I wish I knew how to do the equivalent of a LIMIT clause, but I’m not sure that’s possible.)
Since I’m not using Windows, the MAPI angle wasn’t possible. That’s why I went the DAV route, which is less well documented. It’s still partially experimental DAV, so it’s not widely used outside of Outlook/Exchange.
For my next trick, I will port this to use the JavaScript XMLHTTPRequest object, so it can be embedded directly in the widget instead of requiring a forked PHP CLI process.
Comment by Paul Flatt on 20 September 2005:
Hi Adam,
I’m really interested in what you are doing with PHP pulling in Outlook Calendar information. I would like to be able to do the same, using the resulting data as an in/out board on our Corporate Intranet (running under Mambo/Joomla).
Would it be possible to get access to your code so that I could modify it slightly to do what I need it to?
Regards,
Paul
Comment by Adam Trachtenberg on 21 September 2005:
I will try and dig it up. I’m not sure where I left in, or what state it is in.
Comment by Joe Travaglini on 17 July 2006:
Hey Adam,
Did you ever publish this PHP source anywhere? If so, where? If not, would you be willing to share it?
Comment by Office Outlook on 12 October 2006:
If I have a remote web access to Exchange, what for to me such web service?
Comment by Chris Rutherfurd on 25 January 2008:
Hey Adam,
This seems very interesting. Could this be done the other way around, so that the request for calendar is made from outlook and made to a PHP file.
Comment by Jegan Markandu on 28 February 2008:
I’m making the same request. Could I get to look at your PHP code that pulls the MS Exchange Calendar contents. Thanks
Comment by Adam Trachtenberg on 28 February 2008:
Based on popular request, here is the kludgy bit of code I wrote to do this: http://www.trachtenberg.com/exchange.phps
It uses the PEAR HTTP_Request library. Since I haven’t played with it in years, I don’t know what shape it’s in. I did a minimal clean up to remove my hardcoded information and turn that into variables at the top.
I tried it just now and I am getting Login Timeout errors, but I don’t have the time to debug this.
I think the important part is the format of the request headers, url, and body.
If you get this working, please add a comment here, so people can use what you do.
Thanks!
Comment by drinkJava on 29 March 2011:
You can use header ‘Range’ to request a subset of search results (similar to SQL LIMIT):
Range: rows=0-9
The HTTP standard Range request header is defined for specifying the number of bytes returned. When used with the “rows” specifier, the WebDAV engine recognizes it as indicating the set of rows to return.