Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
aliyun-sms-with-10dlc
Advanced tools
文档地址:https://help.aliyun.com/document_detail/164194.html
#发送号码
mobile = '1646xxxxxxx'
#内容
text = 'code is 19384'
#发送类型
type = 'OTP'
#10DLC号码
from = '1xxxxxxxxxx'
Aliyun::Sms.send_globle(mobile, text, from, type)
Comfortable to aliyun sms 2017-05-25 version api
Currently, aliyun has three services of short message,named:
They all are usable, and will merge togather in future. But before merged, they are Independent, and every user only use one between them.
This gem only for aliyun-sms(阿里云短信服务), and you must confirm that you just use it. If you can't confirm, please see the document 阿里云短信业务说明 to get guidance.
Before use aliyun-sms, you must apply and open the aliyun-sms, and get the parameters as follows:
gem install aliyun-sms
Add in Gemfile :
gem 'aliyun-sms' # Ruby Gems 安装源
Run command:
bundle
Clone and install by rake.
git clone https://github.com/VICTOR-LUO-F/aliyun-sms.git
cd aliyun-sms
rake build
rake install
require 'aliyun/sms'
If you get a error as follows, when running above command:
./config/initializers/aliyun-sms.rb:1:in `<top (required)>': uninitialized constant Aliyun::Sms (NameError)
You could switch to github resource, and modify the the Rails Gemfile to:
gem 'aliyun-sms', '1.1.1', git: 'https://github.com/VICTOR-LUO-F/aliyun-sms.git'
$ require 'aliyun/sms'
return
=> true
$ Aliyun::Sms.configure do |config|
config.access_key_secret = ACCESS_KEY_SECRET
config.access_key_id = ACCESS_KEY_ID
config.action = 'SendSms' # default value
config.format = 'XML' # http return format, value is 'JSON' or 'XML'
config.region_id = 'cn-hangzhou' # default value
config.sign_name = SIGN_NAME
config.signature_method = 'HMAC-SHA1' # default value
config.signature_version = '1.0' # default value
config.version = '2017-05-25' # default value
end
return
=> "2017-05-25"
Send message:
$ Aliyun::Sms.send(phone_numbers, template_code, template_param, out_id)
Explanation:
In Rails direction 'config/initializers/', create file 'aliyun-sms.rb', and add code:
config/initializers/aliyun-sms.rb
Aliyun::Sms.configure do |config|
config.access_key_secret = ACCESS_KEY_SECRET
config.access_key_id = ACCESS_KEY_ID
config.action = 'SendSms' # default value
config.format = 'XML' # http return format, value is 'JSON' or 'XML'
config.region_id = 'cn-hangzhou' # default value
config.sign_name = SIGN_NAME
config.signature_method = 'HMAC-SHA1' # default value
config.signature_version = '1.0' # default value
config.version = '2017-05-25' # default value
end
then, restart Rails application。
Send message in your program:
Aliyun::Sms.send(phone_numbers, template_code, template_param, out_id)
Explanation:
Specially:
In Rails application program, you could organize your message content as a hash, and trans it bo be a param of Aliyun::Sms.send by to_json method. For instance:
...
phone_number = '1234567890'
template_code = 'SMS_12345678'
template_param = {"code"=>"666666", "product"=>"conten" }.to_json
Aliyun::Sms.send(phone_numbers, template_code, template_param)
...
According to Aliyun Official Document example, I had written spect test. You could run the test after clone as follows:
$ bundle exec rspec spec
MIT License。 MIT License.
FAQs
Unknown package
We found that aliyun-sms-with-10dlc demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.