Office365 Weather WebPart

A while ago I wrote a Sharepoint web part that displayed a 5 day weather forecast for a user configurable location using Met Office data from the Azure Datamarket. I wanted to try porting this web part to Office365, to see if I could overcome the challenges of working predominantly client side using Javascript.

With the help of jQuery to make ajax requests to the Datamarket and a cryptographic library to encrypt the username and password that is included in the ajax request headers I've managed to accomplish this goal.

One of the major challenges was to overcome the cross site scripting issues, where I was making requests to the Datamarket from the Office365 domain. The Datamarket supports the oData standard well from a .Net Framework perspective, but it requires user interaction to allow the request from a purely web client or javascript approach. Internet Explorer has an object called a XDomainRequest which is specifically designed for cross site data requests, the only problem is that you can't include any headers, which means that authentication was ruled out. Aparently IE 10 will work the same way that Chrome does now and properly support jQuery CORS. So, I had to compromise and change internet explorer's security settings to allow cross site data requests.

I've just published the code in a CodePlex project here: http://o365Weather.codeplex.com

2 comments:

Dartagnon said...

Any chance you might edit it for use in the US? I've been looking for a similar solution for our intranet for quite some time but haven't found anything.

Ian Chivers said...

The data feed is taken from the Met Office which only supplies UK data. There is a Weather Central feed available which is also free, so the code would just need refactoring to consume that data feed instead. I'd also recommend that the weather data is cached in a hidden list, so that you don't exceed any qoutas imposed on it. I can't see the details of the Super Micro Forecast feed as it's not available in my region. Let me know if you'd like to engage my services on a consultancy/professional basis to help get it implemented.