OneNote API and PHP

Posted in Development on April 30, 2014

onenote api

Recently Microsoft released an API for my brain indexer favourite tool, OneNote.

To say I'm excited by the opportunities presented with this API, especially when it has some more features, would be an understatement. What's really promising is how open the dev team are being about the API's progress and out how quickly they are rolling new stuff out.

The API is particularly interesting to me as I had spent the previous 6 months on and off figuring out how I might get at the data in my Notebooks. Firstly I looked in some depth at how I might implement the syncing protocol MS-FSSHTTP, but that turned out to be a dead end. My fall-back was to teach myself C# and I got pretty far writing a .NET/WPF desktop application which consumed the OneNote COM API, the plan being to use it to stream data out to the cloud to be consumed by other devices.

But I don't need to worry about that now! As soon as the API supports reading content, particularly tags - hint: you can vote for this feature here - then I'll be all over writing the app I've wanted to build for the last 2 years.

Anyway, currently you can create new pages with the API, which is still pretty cool, so I thought that whilst I waited for reading/tag support (you voted, right?) I'd kick the tyres of the API using PHP.

So, firstly I've built a library to do the OAuth 2.0 stuff with the Live Connect API, you can find this on Github or packaged up ready to use with composer. Note that whilst the library will make authenticating against Live Connect Just Work it doesn't yet implement a large number of OneDrive related content retrieval methods - though it should be pretty trivial for you to do this yourself if you need those features too.

The next thing on my list is to create a new library to wrap the OneNote API method by method, but for now here's an example of how easy it is to consume the API once the authentication is taken care of.

The following should work on any web server, I'm using Linux/Apache.

Install

Create composer.json, put this in it:

{
    "require": {
        "siftware/live-connect": "dev-master"
    },
    "autoload": {
        "psr-4": {
            "Siftware\": "src/Siftware"
        }
    }
}

Install composer

curl -s http://getcomposer.org/installer | php
mv composer.phar composer

Pull down the library

./composer install

Create bootstrap.php

Comments (0)