I used to post from my N70 using lifeblog earlier.  I have been looking for a similar feature after I upgraded to N96.   While N70 used to have a simple lifeblog interface, N96 changed that to more feature rich Share Online.  Nokia device is preloaded with Share Online 3.0.  Being an adventurous one, and prefer to be on the cutting edge always, I upgraded my device to new Share Online 4.x.

Phoneboy posted the instructions to post to wordpress from lifeblog last year.  I have been using this in my N70 and it used to work great.  I knew he is smart enough to find a way to post from share online.   I was not surprised when I saw this post a few weeks back.

However, it was not that easy since I use N96 and Share Online 4.x.  I could add my blog as one of the service in the Share Online configured services in the phone.  I couldn’t post as it always failed.   I was not ready to gave up.  Setup requires two php scripts as described in the phoneboy post.  All instructions remain same.  I tried to debug this with the help of phoneboy.

Share Online sends two or more xml files depending on your post.   This can be tracked by enabling (by default) complete dump of phone upload. The first xml file looked something like this…


2009-04-08T01:17:02Z: method: POST
2009-04-08T01:17:02Z: rawpostdata:

06042009004
2009-04-08T19:15:53Z
1
/9j/4AAQSkZJRgABAQAAAQABAZsoO6heBU7x81CykCsnFrckaxFMBwwIpcZ5NN2mkJm1avujHParKHmsvT5D930rTXpVJ3OWasyXGaa8YIoVscU5m4qiTMlG1yKrTcCr90uTkVQmBKmo
aNosqGXBxTfOqKUYY1HmoSNrk5mpPNqIAmlKEdaLIdx5kNKHPao1U5qxHFmk7IaQICRUypxUkceBUqrxSKsQeXRjFTEcVE3BxQFgBxShvWmAc08CmIkU04NUPSl3UCZ/
/2Q==

Nokia N96 (12.043) Series60/3.2 ISF/4.0.08.45

2009-04-14T01:09:15Z: action: post
2009-04-14T01:09:15Z: postaction
2009-04-14T01:09:15Z: filetype: .jpg
2009-04-14T01:09:15Z: filename: /lifeblog-10042009010.jpg
2009-04-14T01:09:15Z: id: url:/lifeblog-10042009010.jpg,type:Image,format:Image,summary:

The data is in the base64 encoded content tag.  lifeblog.php used to parse the code something like this…


} elseif(preg_match('/(?P.*?)<\/title>.*?<content\s*type="(?P<contenttype>.*?)\/(?P<contentsubtype>.*?)"\s*m<br /> ode="(?P<contentmode>.*?)">(?P<content>.*?)<\/content>.*?<br /> <summary>(?P<br /> <summary>.*?)<\/summary>/si', $HTTP_RAW_POST_DATA, $data))<br /> {<br /> </code><br /> But, Share Online sends title with an attribute, type.</p> <p><code lang="xml"> </p> <p><title type="text">06042009004

So the regular expression for preg_match need to be changed to <title.*> in all places.

I have been trying with sample icons in the phone since they are very small and easy to upload.  Problem started when I started uploading actual photographs.  I noticed that preg_match fails when the base64 encoded data is large.  (50-70KB approx).  I googled and found that this is a known problem with PCRE library that php uses for preg_match.   Some references suggested to increase the pcre backtrack_limit as a work around in the php.ini.

[Pcre]
;PCRE library backtracking limit.
pcre.backtrack_limit=5000000

I can post  to my wordpress blog now.  Here are the modified shareonline.php and lifeblog.php.  You will have to change all references to jjaimon.net/blogs in shareonline.php.  Follow the instructions given in the phoneboy blog.