A Ruby interface to the smsc.ru SMS gateway service.
Add this line to your application's Gemfile:
gem 'smscru'
And then execute:
$ bundle
Or install it yourself as:
$ gem install smscru
Global configuration:
Smscru.configure do |config|
config.login = 'smscuser' # Your login
config.password = 'passwordmd5' # MD5 of your password
config.secret = 'smscsecret' # Secret for receiving messages
end
Or:
Smscru.configure(login: 'smscuser', password: 'passwordmd5', secret: 'smscsecret')
client = Smscru::Client.new
client.send_message('Hello world!', '+1234567890')
client.send_message('Hello world!', '+1234567890', id: 456)
client.send_message('Hello world!', '+1234567890', sender: 'TestSender')
client.send_message('Hello world!', ['+1234567890', '+1234567891'])
It's also possible to specify client configuration options:
Smscru::Client.new(login: 'smscuser', password: 'passwordmd5')
URL in settings:
http://example.com/smscru?charset=utf-8&sha1=smscsecret
Use your custom secret instead of smscsecret
.
Routes:
post 'smscru' => 'smscru#callback'
Controller:
require 'smscru'
class SmscruController < ActionController::Base
def callback
callback = Smscru::Callback.new
callback.on_message do |params|
p params # incoming message
end
callback.on_status do |params|
p params # outgoing message status update
end
callback.run(params)
render nothing: true
end
end
You can use proxylocal or ngrok to test your callback handler on local machine.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request