LoginSignup
5
6

More than 5 years have passed since last update.

Wordpressに投稿するスクリプト

Last updated at Posted at 2012-08-18
postWordPress.rb
def postWordPress
  user = 'user'
  post = 'post'
  date = Time.parse('2012/01/01 10:00')
  publish = 0 #0:下書き,1:公開 
  description = '内容'

  server = XMLRPC::Client.new('sample.com', '/xmlrpc.php') #/(スラッシュ)は必須

  struct = {
    'title' => 'title',
    'description' => description,
    'dateCreated' => date
  }

  id = server.call("metaWeblog.newPost",1,user,pass,struct,publish)
  puts "Posted ID: #{ID}"
end

xmlrpc.phpの指定の直前のスラッシュは指定がないと400 Bad Requestが出てしまう

post.rb
load postWordPress
postWordPress

で投稿可能

5
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6