IfreeSms
The IfreeSms gem for i-free sms provider
Install
gem 'ifree-sms'
rails generate ifree_sms:install
Usage
Use middleware with options:
config.app_middleware.use IfreeSms::Manager do |c|
c.routes = "/ifree/sms"
end
Initialize IfreeSms and set its configurations.
# config/initializers/ifree_sms.rb
if Object.const_defined?("IfreeSms")
IfreeSms.setup do |config|
config.secret_key = ""
config.project_name = ""
config.service_number = ""
config.debug = true
end
IfreeSms::Manager. do |env, |
# set it if you want to send answer for user
.answer_text = "put here sms answer for user"
end
end
Send sms message to user (asynchronous)
* phone - format => 380971606179
* text - length => 160 Latin or 70 Unicode (encoding utf-8)
* from - sender title, max length: 11
smsdirect = IfreeSms::SMSDirectAPI.new(login, password)
smsdirect.submit_message(phone, text, from)
or
IfreeSms::Message.first.send_answer("some text")
Dependences
-
sudo apt-get install libcurl3 libcurl3-gnutls libcurl4-openssl-dev