Dan Poltawski's Blog

Abusing the Moodle Repository API With Guardian Open Platform

I read about the launch of the Guardian Open Platform and immediately thought it was cool, later considering how awesome it might be for teachers trying to find resources to support their teaching – I wanted to play. The prospect of a teacher having access to search and embed all the content which was made available from the guardian sounded great & seemed like a job for a Moodle 2.0 respository plugin – so I applied for an API key.

Last week my request for an API key was finally accepted and I spent an hour or so playing with the API last night. My first thought when reading about Guardian open platform was the prospect of using it to find and embed images. Unfortunately the platform doesn’t explicitly support images at this time, and videos are supported only as a link to the source page. This means that it didn’t explicitly fit with the way other repo plugins work. The guardian platform does support the full body of text articles being retrieved and so I created a very hacky plugin which would return the body of an article in the same way youtube video links are embeded with the youtube plugin. This was mostly pointless other than for my own satisfaction as there is nothing to receive this in the editor properly without copy and paste. It seems like its probably an abuse of the repository API to not retrieve files, but it was fun to play with it.

I’m not sure if the repository API is the appropriate place for embedding this content and there are significant barriers with the guardian license terms for this to be a useable plugin. The license terms for the platform wouldn’t necessarily suit teaching at this time (content shouldn’t be stored for more than 24 hours – though it would be fine to re-request it), but of course this shouldn’t be a blocker to see if the technology would work. A lot of educational institutes have access to newspaper content via means such as lexis nexis and i’m sure a potential licensing solution for education could be developed, so its fun to play with.

On a technical level I used the openplatform-php library which guardian provide and I didn’t really like. I didn’t like it as it generated php warnings a plenty, and I wasn’t feeling particularly motivated to rewrite all these bits, so I hacked each one I came across away in a really crappy way. The really short source code (respository.php is the only actual moodle source) can be found in my git repo. Though its not that useful (as I say, just hacking in an hour) and amongst other things doesn’t deal with problems of requesting content daily according to the license terms. Even so, fun to play with open apis and integrate.

Simon Willison gave a great introduction to the whole platform, including the data store – which is equally cool.

Comments