10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/ruby_sipgate/sms.rb', line 10
def self.deliver(phonenumber, text)
user = RubySipgate::Config.get :username
url = "https://#{user}:#{RubySipgate::Config.get :password}@samurai.sipgate.net/RPC2"
client = XMLRPC::Client.new2(url)
client.call('samurai.ClientIdentify', {'ClientName' => 'Ruby-Client'} )
number = strip_phonenumber(phonenumber)
args = {
'RemoteUri' => "sip:#{number}@sipgate.net",
'TOS' => 'text',
'Content' => text[0,159]
}
if RubySipgate::Config.get :debug
puts "*** I would have sent the following to #{phonenumber}:"
puts args.inspect
else
if r = client.call('samurai.SessionInitiate', args)
if RubySipgate::Config.get :verbose
puts "*** SMS sent to #{number} (#{r.inspect})"
puts "*** SMS text: #{text}"
end
return r
else
raise "sms send failed: #{r.inspect}"
end
end
end
|