0.01
No commit activity in last 3 years
No release in over 3 years
Send short message via aliyun cloud service.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

> 1.14
>= 12.3.3
>= 3.0

Runtime

>= 2.0
 Project Readme

Aliyun::CloudSms

This gem is used for sending sms via aliyun sms service, and querying the message status as well.

中文文档 Chinese document

Installation

Add this line to your application's Gemfile:

gem 'aliyun-cloud_sms'

And then execute:

$ bundle

Or install it yourself as:

$ gem install aliyun-cloud_sms

Construct a client

Global account

Create file aliyun-cloud_sms.rb to your config/initializers.

Aliyun::CloudSms.configure do |config|
  config.access_key_secret = 'your key secret'
  config.access_key_id = 'your key id'
  config.sign_name = 'your sign name'
end

Multiple account support

If you want to send message with multiple sign name, you can build your own message sender client.

client = Aliyun::CloudSms.new('your_access_key_id', 'your_access_key_secret', 'your_sign_name')

## API
### Message send
```ruby
Aliyun::CloudSms.send_msg(mobile, template_code, template_param).

e.g.

Aliyun::CloudSms.send_msg('13800000000', 'SMS_80190090', {"customer": "jere"} )

template_params could be a string.

client.send_msg('13800000000', 'SMS_80190090', "{\"customer\":\"jeremy\"}" )

extended params support

Aliyun::CloudSms.send_msg('13800000000', 'SMS_80190090', {"customer": "jere"}, {:OutId => 'your system id', :smsUpExtendCode => 'sms up extended code'} )

Status query

client.query_status(mobile, send_date = "#{Time.now.strftime('%Y%m%d')}", biz_id = nil, page_size = 1, current_page = 1)

# e.g.
client.query_status '13800000000'
client.query_status '13800000000', '20170806'
client.query_status '13800000000', '20170806', '109177619494^4112265203597'
client.query_status '13800000000', '20170806', nil, 10
client.query_status '13800000000', '20170806', nil, 10, 2

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Welcome pull request. Hope help.

License

The gem is available as open source under the terms of the MIT License.