开发者

400 Bad Request error when using XMLRPC and RoR (3.1, 1.9.2) to post to a wordpress installation

开发者 https://www.devze.com 2023-02-02 20:39 出处:网络
I am attempting to post a blog post to a wordpress blog using XMLRPC.Here is the code I am using: def post(article)

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号