[英]Can't use RubyPress gem gives getaddrinfo: No such host is known. (SocketError)
I am trying to use a gem called RubyPress which allows to use Wordpress' xml-rpc api from ruby. 我正在尝试使用一个名为RubyPress的宝石,该宝石可以使用来自ruby的Wordpress的xml-rpc api。 But it always gives me this error:
但这总是给我这个错误:
getaddrinfo: No such host is known. (SocketError)
Here's my code: 这是我的代码:
require 'rubypress'
wp = Rubypress::Client.new(:host => "localhost/wordpress",
:username => "admin",
:password => "admin")
p wp.getOptions
I am able to connect fine using another gem called wp_rpc but rubypress doesn't seem to work. 我可以使用另一个名为wp_rpc的 gem很好地连接,但是rubypress似乎不起作用。 Rubypress seems to be maintained so i want to use it, it also seems to have more features.
Rubypress似乎得到了维护,因此我想使用它,它似乎还具有更多功能。
Also, even when i try connecting to a real site, it gives a 403 error which is very strange. 另外,即使我尝试连接到真实站点,它也会显示403错误,这非常奇怪。
I am running the server using XAMPP on Windows 7. How can I get it to work? 我正在Windows 7上使用XAMPP运行服务器。如何使它工作?
UPDATE: Here's the code i used for posting, now it doesn't seem to post. 更新:这是我用于发布的代码,现在似乎没有发布。 Not sure where i went wrong.
不知道我在哪里错了。
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']
}
}
)
Note: This is from the rubypress github page. 注意:这来自rubypress github页面。 Those categories and tags are not present on the blog, is that the reason?
这些类别和标签没有出现在博客上,这是原因吗?
host
must be a host name (eg "localhost"
in this particular case, or, say, "google.com"
): host
必须是一个主机名(例如,在这种情况下为"localhost"
,例如"google.com"
):
require 'rubypress'
wp = Rubypress::Client.new(host: "localhost",
username: "admin",
password: "admin",
path: "/wordpress/xmlrpc.php")
Probably, you might need to tune the path
parameter up to point exactly to where WP's RPC endpoint is to be found. 可能您可能需要调整
path
参数,以精确指向要在其中找到WP的RPC端点的位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.