use html formatted uri in Ruby
I need to send mails via a webapi (Dreamhost). By accessing a url with encoded parameters you can define the email.
one of the parameters is the message in html format.
I use the open() method to acces the url but get a
URI::InvalidURIError
I can reformat the url by using URI.parse and URI.encode but this reformats the html in a unwa开发者_运维百科nted state.
Is there a way I can embed html and open the url in Ruby?
Thanks
Use CGI.escape.
require 'cgi'
"http://example.com?message=#{CGI.escape('This is the message body!')}"
精彩评论