I’ve been experimenting with Share on Ovi this week (seems only proper now that we’re all part of the same family now). Turns out to be a very nicely put-together web app in the Flickr genre, but with much better mobile integration, at least on Nokia devices.
Programatically uploading media to Share on Ovi can be done using the Atom Publishing Protocol: the basic idea is that you do an HTTP POST of binary image data, get back a response that contains an endpoint for doing an HTTP PUT with the image meta-data.
While I’m an old hand at using PHP and cURL together, this was the first time I’d needed to do an HTTP POST that wasn’t a standard key-value pairs, but rather simply a binary file. Turns out this is pretty easy, once you figure it out; the keys are:
$upload = file_get_contents($filename);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $upload);
Once I got this together, and figured out the secret WSSE voodoo required to authenticate, everything fell into place: here’s the first image I uploaded with my cool new PHP class.