So I’m trying to write a desktop app to publish posts to a WordPress blog, and I found Reuben Stanton’s WordPress XML-RPC library (for some reason, his site isn’t responding, so here’s the code on Google Code)
Now everything works well, but when I get to publishing posts, something weird happens.
Here’s my code:
private function publish():void {
var sel:CuratorBlog=blogSelect.selectedItem;
publisher=new WPService(sel.url, sel.login, sel.password);
publisher.addEventListener(WPServiceEvent.NEW_POST, postAdded);
var p:Post=new Post();
p.dateCreated=publishDate.selectedDate;
p.title=txtTitle.text;
p.mt_keywords=txtTags.text;
p.mt_allow_comments=1;
p.mt_allow_pings=1;
p.description=htmlText; //This is obtained from a richText control. And yes, I have tested that it is being assigned properly
publisher.posts.newPost(p, true);
btnPublish.enabled=false;
cursorManager.setBusyCursor();
}
private function postAdded(e:WPServiceEvent):void {
var postId:String=(e.data as String);
Alert.show(blogSelect.selectedItem.url + "?p=" + postId);
publisher.removeEventListener(WPServiceEvent.NEW_POST, postAdded);
cursorManager.removeBusyCursor();
btnPublish.enabled=true;
}
The issue is that the post is created, but without the content.
I am able to see the tags and title in the browser when I open the blog, but it has no content. any idea why? How can I fix it?
Wow!! I am turning into a self-answerer (for lack of a better term) 😛
Turns out something was reading the content and doing a sort of
htmlUnescape
on it.So, I did a
htmlEscape
before I posted it, and it worked!!A class for Html escaping and unescaping can be found from http://thingsthatwork.net/index.php/2008/06/26/html-entities-and-actionscript/