SMSCentre
Send SMS via SMS Centre gateway
Installation
Add this line to your application's Gemfile:
gem 'sms_centre'
And then execute:
$ bundle
Or install it yourself as:
$ gem install sms_centre
Usage
- Register at http://smscentre.com
Create api object:
api = SMSCentre::API.new('your_login', 'your_password')
Send sms:
# Single phone result = api.broadcast('PHONENUMBER1', 'This is message text') # Multiple phones result = api.broadcast(['PHONENUMBER1', ...], 'This is message text') # Optional, you can set sender name and message id (can be used for status check) result = api.broadcast('PHONENUMBER1', 'This is message text', params: {sender: 'SENDER NAME', id: 'MESSAGE_ID'} # Get phone status code result.status_for 'PHONENUMBER1' # Or get localized status string (only russian supported yet) result.human_status_for 'PHONENUMBER1'
Get sms status by phone number and message id:
status = api.status('MESSAGE_ID', 'PHONENUMBER1') # Get status code status.status # Get get localized status string status.human_status # More generic status checks status.delivered? # Is message delivered? status.pending? # Is message in queue yet? status.failed? # Is message delivery failed for some reason?
Check your balance:
api.balance # => '999.99'
Configure
Paste this code in some file, load it before send sms (rails hint: initializer is the best place to do it)
SMSCentre.configure.do |config|
# For example, disable SSL
config.use_ssl = false
end
See options list in source code
Contributing
- 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