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

  1. Register at http://smscentre.com
  2. Create api object:

    api = SMSCentre::API.new('your_login', 'your_password')
    
  3. 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'
    
  4. 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?
    
  5. 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

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request