您将如何从Web应用程序将消息作为短信发送到电话,反之亦然?

问题描述

|                                                                                                                   关闭。这个问题需要更加集中。它当前不接受答案。                                                      

解决方法

        通过http://www.twilio.com/对开发人员最友好的方式发送SMS     ,        我使用了www.clickatell.com,它们具有api和用于访问其api的ruby gem。有关该宝石的更多信息,请参见:http://clickatell.rubyforge.org/     ,        如果您在heroku上部署,则还必须将Moonshadow作为附件。我建议您检查不同的短信网关,因为价格各不相同     ,        您可以检查http://www.bluevia.com     ,        从短信网关提供商处购买积分。 如果您正在Rails 3.x上工作,请在您的环境文件中添加require \'net / http \(对于rails 2应用程序不是必需的)。
def send_welcome_sms
  url=URI.parse(\"http://webaddress.com\");
  request = Net::HTTP::Post.new(url.path)  
  message = \"message goes here\"
  request.set_form_data({\'username\'=>\"abc\",\'password\'=>\"xyz\",\'to\'=> \"some number\",\'text\'=> \"#{message}\",\'from\'=> \"someone\"})
  response = Net::HTTP.new(url.host,url.port).start {|http| http.request(request) }
  # If U are Behind The Proxy Comment Above Line And  Uncomment Below Line,Give The Proxy Ip & Port
  #response = Net::HTTP::Proxy(\"PROXY IP\",PROXYPORT).new(url.host,url.port).start {|http| http.request(request) }

  case response
  when Net::HTTPSuccess
    puts response.body
  else
    response.body
    response.error!
  end
end
    

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...