项目作者: timlentse

项目描述 :
Ruby SDK For Aliyun SMS Service
高级语言: Ruby
项目地址: git://github.com/timlentse/aliyun_sms.git
创建时间: 2017-03-22T10:57:54Z
项目社区:https://github.com/timlentse/aliyun_sms

开源协议:MIT License

下载


AliyunSms

Installation

Add this line to your application’s Gemfile:

  1. gem 'aliyun_sms'

And then execute:

  1. $ bundle

Or install it yourself as:

  1. $ gem install aliyun_sms

Usage

1. Configure first

  1. AliyunSms.configure do |config|
  2. config.access_key_id = 'testid'
  3. config.access_key_secret = 'testsecret'
  4. # config.format = "XML" ## optional(default 'JSON')
  5. # config.region_id = "cn-hangzhou" ## optional
  6. end

2. Send a message

  1. args = {:phone=>"123456789",:sign_name=>"标签测试", :tpl_id=>"SMS_1650053", :params=>{"code":"1234"}}
  2. AliyunSms.to args

Integrated with Rails

Put a files(named aliyun_sms.rb for example) in config/initializers/ and the content can be the following:

  1. ## config/initializers/aliyun_sms.rb
  2. AliyunSms.configure do |config|
  3. config.access_key_id = 'testid'
  4. config.access_key_secret = 'testsecret'
  5. # config.format = "XML" ## optional(default 'JSON')
  6. # config.region_id = "cn-hangzhou" ## optional
  7. end

Now You can send a message in controller:

  1. AliyunSms.to {:phone=>"123456789",:sign_name=>"标签测试", :tpl_id=>"SMS_1650053", :params=>{"code":"1234"}}

Contributing

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.

License

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