Solved the NSXMLParserErrorDomain error in WordPress for iPhone

November 11th, 2009 | Categories: Site, Software | Tags: ,

There's a wonderful free app for the iPhone with which to manage one or more Wordpress blogs: WordPress for iPhone. This app was recently rewritten and is now at version 2.0.

Unfortunately, I was never able to get the app to list the comments on my site, something I really wanted to have, in order to approve or spam a particular item.

This evening I decided to tackle the problem by first launching the app against a test WordPress I have on my laptop. I was rather pleasantly surprised to not get the dreaded NSXML ParserErrorDomain or error 500 errors. Being a test blog, the reason could only be that it had very few comments in it.

Bingo!

I then quickly edited the xmlrpc.php file on my site (i.e. what you are reading here) and hacked in a line limiting the number of comments to be returned via XML-RPC.

*** xmlrpc.php.orig     2009-11-11 20:35:21.000000000 +0100
--- xmlrpc.php  2009-11-11 20:35:21.000000000 +0100
***************
*** 1136,1141 ****
--- 1136,1142 ----
                if ( isset($struct['number']) )
                        $number = absint($struct['number']);

+ $number = 40; # JPM
                $comments = get_comments( array('status' => $status, 'post_id' => $post_id, 'offset' => $offset, 'number' => $number ) );
                $num_comments = count($comments);

It worked:

If anybody's reading this, this is not the real solution. It is a hack. It is, however, a hack I like because, if it is the intention of the WordPress for iPhone App authors to retrieve all comments, that is a lousy idea. It takes time, costs resources, and it puts quite a burden on carrier costs, unless you have a flat rate.

In other words: I like my hack. :-)

No comments yet.