Add this line to your application's Gemfile:
gem 'aliyun_sms'And then execute:
$ bundleOr install it yourself as:
$ gem install aliyun_smsAliyunSms.configure do |config|
config.access_key_id = 'testid'
config.access_key_secret = 'testsecret'
# config.format = "XML" ## optional(default 'JSON')
# config.region_id = "cn-hangzhou" ## optional
endargs = {:phone=>"123456789",:sign_name=>"标签测试", :tpl_id=>"SMS_1650053", :params=>{"code":"1234"}}
AliyunSms.to argsPut a files(named aliyun_sms.rb for example) in config/initializers/ and the content can be the following:
## config/initializers/aliyun_sms.rb
AliyunSms.configure do |config|
config.access_key_id = 'testid'
config.access_key_secret = 'testsecret'
# config.format = "XML" ## optional(default 'JSON')
# config.region_id = "cn-hangzhou" ## optional
endNow You can send a message in controller:
AliyunSms.to {:phone=>"123456789",:sign_name=>"标签测试", :tpl_id=>"SMS_1650053", :params=>{"code":"1234"}}Bug reports and pull requests are welcome on GitHub at https://github.com/timlentse/aliyun_sms. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.