class SMS
Simple way to send sms through Ozeki Phone System XE or Ozeki NG SMS
Gateway.
Public Class Methods
ng_send_sms(ng_ip_address, username, password, to, message, port=9501, from=nil)
click to toggle source
Class method to send an SMS
message through Ozeki NG SMS
Gateway
# File lib/ozeki_sms.rb, line 9 def self.ng_send_sms ng_ip_address, username, password, to, message, port=9501, from=nil to = URI::encode(to) message = URI::encode(message) from ||= "" uri = URI "http://#{ng_ip_address}:#{port}/api?action=sendmessage&username=#{username}&password=#{password}&originator=#{from}&recipient=#{to}&messagetype=SMS:TEXT&messagedata=#{message}" Response.create Net::HTTP.get uri end
ops_send_sms(ops_ip_address, api_extension, to, message, http_api_service_port=7780, from=nil, delivery_report_url=nil, username=nil, password=nil)
click to toggle source
Class method to send an SMS
message through Ozeki Phone System XE
# File lib/ozeki_sms.rb, line 18 def self.ops_send_sms ops_ip_address, api_extension, to, message, http_api_service_port=7780, from=nil, delivery_report_url=nil, username=nil, password=nil to = URI::encode(to) message = URI::encode(message) from ||= "" from = URI::encode(from) delivery_report_url ||= "" delivery_report_url = URI::encode(delivery_report_url) http_api_service_port ||= 7780 SMS.execute_query "http://#{ops_ip_address}:#{http_api_service_port}/?Command=SendSms&ApiExtension=#{api_extension}&Sender=#{from}&Recipient=#{to}&Message=#{message}&DeliveryReportURL=#{delivery_report_url}", username, password end
Private Class Methods
execute_query(query, username, password)
click to toggle source
# File lib/ozeki_sms.rb, line 32 def self.execute_query query, username, password if (username != nil) && (password != nil) query += "&username=#{username}&password=#{password}" end uri = URI query Response.create Net::HTTP.get uri end