WordPress error when connecting from a desktop writer application

My adventures with the wordpress aren’t over yet !

Today I downloaded Windows live writer and tried to use it to write posts on my blog as the default editor of wordpress seemed too simple for me. As the site was working fine via the browser, I thought that all is really well.

But as Live writer tried to connect to the blog, it gave me the following error

Invalid server response รขโ‚ฌโ€œ The response to the blogger.getUserBlogs method received from the blog server was invalid : blah blah blah

This is the error if you fancy reading it

image

 

So I tried to open the http://198.1.75.221/~amilagmc/xmlrpc.php from the browser. Bang it failed too !!!

As the error had some useful information with it I opened the xmlrpc.php from my local folder and checked the line with the error. It was the 30th line :

include('./wp-load.php');

Just like in my previous post I changed that line to

include('wp-load.php');

and uploaded the file. Then tried the http://198.1.75.221/~amilagmc/xmlrpc.php again. Then it gave me this

XML-RPC server accepts POST requests only.

Ok looks like it is working now ๐Ÿ˜€ . Back to Windows Live Writer.

It falied again with the same error ๐Ÿ™

Then I checked the XML response returned from the wordpress via the charles proxy and it showed that a part of the closing </methodResponse> tag was missing actually it was like </methodRespo. So the returning xml was invalid and that caused the error. 

After about 2 hours of digging through the wordpress source I finally found the culprit ๐Ÿ™‚

So here’s the strangest part

In the \wp-includes folder there is a file named class-IXR.php. In the line 332 of that, there’s a statement

$xml = <<<EOD
<methodResponse>
  <params>
    <param>
      <value>
        $resultxml
      </value>
    </param>
  </params>
</methodResponse>

EOD;

Note that there is only one blank line between the </methodResponse> and EOD. When I increased the number of blank lines, the missing parts of the  </methodResponse> began appearing gradually.

Finally I added 5 blank lines before the EOD; and bang it is working. Now the final code looks like this

$xml = <<<EOD
<methodResponse>
  <params>
    <param>
      <value>
        $resultxml
      </value>
    </param>
  </params>
</methodResponse>





EOD;

I have no earthly idea how this is happening. But however it is working fine. I am hosting this site on a Windows Server 2008 box with IIS 7.0 and PHP 5.X may be it is an issue with running php on windows.

Anyway all is well at least for now ๐Ÿ˜€

Happy blogging