简体   繁体   English

无法使用RubyPress gem提供getaddrinfo:尚无此类主机。 (SocketError)

[英]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.

相关问题 “获取错误” getaddrinfo:没有此类主机。 (Socke tError)”与机械化宝石 - Getting error “getaddrinfo: No such host is known. (Socke tError)” with mechanize gem 随着Nokogiri我得到错误“初始化”:getaddrinfo:没有这样的主机是已知的。 (SocketError)” - With Nokogiri i am getting error “initialize': getaddrinfo: No such host is known. (SocketError)” 如何解决SocketError:getaddrinfo:Ruby中没有这样的主机? - how to solve SocketError: getaddrinfo: No such host is known in Ruby? Seahorse :: Client :: NetworkingError(getaddrinfo:未知此类主机。),同时使用回形针将图像上传到s3并用于heroku应用程序 - Seahorse::Client::NetworkingError (getaddrinfo: No such host is known. ) while uploading image to s3 using paperclip for heroku app Elasticsearch SocketError(getaddrinfo:名称或服务未知) - Elasticsearch SocketError (getaddrinfo: Name or service not known) /home/web/.gem/ruby/2.2.0/gems/redis-3.2.1/lib/redis/connection/ruby.rb:152:in`getaddrinfo':getaddrinfo:名称或服务未知(SocketError) - /home/web/.gem/ruby/2.2.0/gems/redis-3.2.1/lib/redis/connection/ruby.rb:152:in `getaddrinfo': getaddrinfo: Name or service not known (SocketError) Rails服务器错误“初始化”:getaddrinfo:名称或服务未知(SocketError) - rails server error `initialize': getaddrinfo: Name or service not known (SocketError) SSL 证书 getaddrinfo:名称或服务未知(SocketError)Rails-4.2.0 - SSL Certificate getaddrinfo: Name or service not known (SocketError) Rails-4.2.0 Net :: HTTP SocketError:getaddrinfo:提供的节点名或服务名,或者未知 - Net::HTTP SocketError: getaddrinfo: nodename nor servname provided, or not known 如何处理SocketError - getaddrinfo:提供nodename或servname,或者不知道[ruby] - How to handle SocketError - getaddrinfo: nodename nor servname provided, or not known [ruby]
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM