ルビーからWordpressのxml-rpc APIを使用できるRubyPressというgemを使用しようとしています。しかし、それは常に私にこのエラーを与えます:
getaddrinfo: No such host is known. (SocketError)
これが私のコードです:
require 'rubypress'
wp = Rubypress::Client.new(:host => "localhost/wordpress",
:username => "admin",
:password => "admin")
p wp.getOptions
wp_rpcという別の gem を使用して正常に接続できますが、rubypress は機能していないようです。Rubypressも整備されているようで使いたい、機能も充実しているようです。
また、実際のサイトに接続しようとしても、非常に奇妙な 403 エラーが発生します。
Windows 7 で XAMPP を使用してサーバーを実行しています。
更新:投稿に使用したコードは次のとおりです。現在、投稿されていないようです。どこで間違ったのかわかりません。
wp.newPost( :blog_id => 0, # 0 unless using WP Multi-Site, then use the blog id
:content => {
:post_status => "publish",
:post_date => Time.now,
:post_content => "This is the body",
:post_title => "RubyPress is the best!",
:post_name => "/rubypress-is-the-best",
:post_author => 1, # 1 if there is only the admin user, otherwise the user's id
:terms_names => {
:category => ['Category One','Category Two','Category Three'],
:post_tag => ['Tag One','Tag Two', 'Tag Three']
}
}
)
注: これは rubypress github ページからのものです。それらのカテゴリとタグがブログに存在しないのは、それが理由ですか?