0

我正在编写一个短信发送功能,但它似乎没有发送短信。
看到这段代码有什么想法吗?

def self.send_sms(to, from, message)

username = "uname"
password = "pword"
id = rand(36**8).to_s(36)
dlr_url = URI::escape('http://www.skylinesms.com/messages/delivery?id=#{id}&type=%d')
send_url = 'http://localhost:13013/cgi-bin/sendsms?username=#{username}&password=#{password}&to=#{to}&from=#{from}&text=#{message}&dlr-url=#{dlr_url}&dlr-mask=3'
url = URI.parse(URI.encode(send_url))            
req = Net::HTTP::Get.new(url.to_s)
res = Net::HTTP.start(url.host, url.port) {|http|  http.request(req)   }
return res.body

end
4

1 回答 1

0

我不确定,但我认为是的

def self.send_sms(to, from, message)
    .....
    Net::HTTP.start(url.host, url.port) { |http| http.get(req.request_uri).body }
  end
于 2013-09-04T19:23:12.323 回答