开发者

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!')}"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜