I am attempting to post a blog post to a wordpress blog using XMLRPC. Here is the code I am using:
def post(article)
my_new_blog_post = {
:description => article.article_texts.last.content,
:title => article.article_title,
:excerpt => '',
:categories => [],
:post_status => 'publish'
}
server = XMLRPC::Client.new(url)
# Returns the ID o开发者_运维百科f the new post, or fail
resp = server.call("metaWeblog.newPost", 0, site_login, site_password , my_new_blog_post)
end
Everything is created correctly, including the login and password, but for some reason I keep getting a 400 Bad Request error. I logged in on the wordpress site and it worked with the username and password, so I thought maybe there are some incompatibilities with the newest ruby and the XMLRPC client. If so, is there some other method I should be using that would accomplish the same results?
Thanks!
Not sure if this will help anyone, but figured I should put it up here. I just had to call XMLRPC::Client.new2(url)
instead. Apparently this other type of client works.
精彩评论