require ‘net/http‘
require ‘uri‘
require ‘json‘
params = {
"account" => "",
"password" => "a.123456",
"mobile" => "8615800000000",
"msg" =>URI::escape("【253云通讯】您好,您的验证码是999999")
}.to_json
def send_data(url,data)
url = URI.parse(url)
req = Net::HTTP::Post.new(url.path,{‘Content-Type‘ => ‘application/json‘})
req.body = data
res = Net::HTTP.new(url.host,url.port).start{|http| http.request(req)}
puts res.body
end
send_data(‘http://intapi.253.com/send/json‘,params)
原文:http://blog.51cto.com/13567544/2150143