Class: Aliyun::Dysms

Inherits:
Connector::RPCClient show all
Defined in:
lib/aliyun/dysms.rb

Instance Attribute Summary

Attributes inherited from Connector::RPCClient

#access_key_id, #access_key_secret, #api_version, #codes, #endpoint, #opts, #security_token, #verbose

Instance Method Summary collapse

Methods inherited from Connector::RPCClient

#request

Constructor Details

#initialize(config = {}, verbose = nil) ⇒ Dysms

本产品(Dysmsapi/2017-05-25)的OpenAPI采用RPC签名风格,签名细节参见签名机制说明。 我们已经为开发者封装了常见编程语言的SDK,开发者可通过下载SDK直接调用本产品OpenAPI而无需关心技术细节。



7
8
9
10
11
# File 'lib/aliyun/dysms.rb', line 7

def initialize(config = {}, verbose = nil)
  config[:endpoint]    ||= "http://dysmsapi.aliyuncs.com"
  config[:api_version] ||= "2017-05-25"
  super(config, verbose)
end

Instance Method Details

#send_sms(phone_numbers, template_code, template_param, sign_name = "") ⇒ Object

发送短信,发送前要申请短信签名和短信模板,并确保签名和模板已审核通过。



14
15
16
17
18
19
20
21
22
23
# File 'lib/aliyun/dysms.rb', line 14

def send_sms(phone_numbers, template_code, template_param, sign_name = "")
  params = {
    PhoneNumbers:  phone_numbers,
    SignName:      sign_name,
    TemplateCode:  template_code,
    TemplateParam: template_param.to_json
  }
  opts   = { method: "POST", timeout: 15000 }
  request(action: "SendSms", params: params, opts: opts)
end