0
我試圖訪問Dreamhost API來發送郵件。創建複雜的網址
的API預計含有域的地址與實際emailcontent
domain = 'https://api.dreamhost.com/' key = "dq86ds5qd4sq" command = "announcement_list-post_announcement" mailing = "mailing" domain = "domain.nl" listname = "mailing Adventure"<[email protected]>" message = '<html>html here</html>' url = domain + "&key=#{key}&cmd=#{command}&listname=#{mailing}&domain=#{domain}&listname=#{listname}&message=#{message}" uri = URI.parse(url) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true if uri.scheme == "https" # enable SSL/TLS http.verify_mode = OpenSSL::SSL::VERIFY_NONE http.start { # http.request_get(uri.path) {|res| # print res.body # } }
當我解析URL,我得到一個錯誤
壞URI(是不是URI?)
url包含來自listname和message的url本身我認爲這會導致問題。我不知道如何去讚美這件事。 CGI escpae已被提出,但似乎將空白轉換爲+。
有人知道如何解決這個問題嗎?
感謝