WordPress XMLRPC API post (html) error parse error not well formed

I am using WordPress’s XMLRPC API and the IXR_Library php class for WP API. wp.newPost is working normally if I use plain text or just simple text in body/content of the post but when I am posting a autocreated full html/shortcode content, it always gives me this error

Array ( [faultCode] => -32700 [faultString] => parse error. not well formed ) 

The content I am trying to post is a post content I normally use within WP with shortcodes but I want to post it via php using API since I am trying to automate my blogging.
You can check the body/content I am trying to post below
http://pastebin.com/U94XVZGT
Thats the content thats shown in XML debug mode (probably seems already html encoded)
Below is the full XML call and response returned via debugging, have removed user/pass from it
http://pastebin.com/26Nyx97K

Read More

I would really appreciate any possible help, I have already tried php’s htmlentities and htmlspecialchar functions to encode my body and even tried str_replace to replace[ ] brackets in thought that they might be causing it

Again, its certainly due to the content code as I tried just a Hello World plain content and it worked ————————————————————
A Update, earlier I was getting the html content from a textarea using $_POST, just now I tried to use same content in same variable but used ‘ ‘ single quotes instead around the content body and now posting works but I get a error

Warning: strpos(): Empty delimiter in wp-includes/class-wp-xmlrpc-server.php on line 4338

So if I use $body=$_POST[‘body’]; it doesnt works and gives main error but directly using $body=’ htmlcontent inside ‘; works but gives above strpos error

Related posts

Leave a Reply

4 comments

  1. TO anyone else having this problem, I fixed it. At end of it seemed the problem was due to wrong character encoding, I needed to Pass UTF8 but the content was being passed in some other char encoding (windows one) making some text and other languages not parseable, I modified my code to make it UTF 8 and now it works

  2. I’ve changed my password to contain no symbols and it solved the issue.

    I’m still not sure what broke everything initially but you might as well try changing it and trying again and see if that works for you.