Class: Alibaba::Bigfish

Inherits:
Object
  • Object
show all
Defined in:
lib/alidayu.rb

Instance Method Summary collapse

Constructor Details

#initialize(key, secret) ⇒ Bigfish

Returns a new instance of Bigfish.



7
8
9
10
# File 'lib/alidayu.rb', line 7

def initialize(key, secret)
  @key = key
  @secret = secret
end

Instance Method Details

#send_sms(params = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/alidayu.rb', line 12

def send_sms(params={})
  required_params = {app_key: @key,
                     format: 'json',
                     method: 'alibaba.aliqin.fc.sms.num.send',
                     sign_method: 'md5',
                     timestamp: Time.now.strftime("%Y-%m-%d %H:%M:%S"),
                     v: '2.0',
                     rec_num: params[:rec_num],
                     sms_free_sign_name: params[:sms_free_sign_name],
                     # sms_param: "{'code':123456','product':'药药灵','item':'吃药'}",
                     sms_param: params[:sms_param].to_json,
                     sms_template_code: params[:sms_template_code],
                     sms_type: 'normal'}

  sign = sign_parmas(required_params)
  signed_parmas = required_params.merge({sign: sign})

  uri = URI('http://gw.api.taobao.com/router/rest')
  res = Net::HTTP.post_form(uri,signed_parmas)
  return res.body
end