https://github.com/timlentse/aliyun_sms
Ruby SDK For Aliyun SMS Service
https://github.com/timlentse/aliyun_sms
aliyun-sms ruby
Last synced: 4 months ago
JSON representation
Ruby SDK For Aliyun SMS Service
- Host: GitHub
- URL: https://github.com/timlentse/aliyun_sms
- Owner: timlentse
- License: mit
- Created: 2017-03-22T10:57:54.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-07-03T15:33:06.000Z (almost 9 years ago)
- Last Synced: 2025-11-29T17:34:10.559Z (7 months ago)
- Topics: aliyun-sms, ruby
- Language: Ruby
- Homepage:
- Size: 8.79 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# AliyunSms
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'aliyun_sms'
```
And then execute:
```sh
$ bundle
```
Or install it yourself as:
```sh
$ gem install aliyun_sms
```
## Usage
### 1. Configure first
``` ruby
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
end
```
### 2. Send a message
``` ruby
args = {:phone=>"123456789",:sign_name=>"标签测试", :tpl_id=>"SMS_1650053", :params=>{"code":"1234"}}
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:
```ruby
## 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
end
```
Now You can send a message in controller:
```ruby
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](http://contributor-covenant.org) code of conduct.
## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).