1 | <?php |
||
12 | class AlidayuAgent extends Agent |
||
13 | { |
||
14 | public function sendSms($tempId, $to, array $data, $content) |
||
18 | |||
19 | public function sendContentSms($to, $content) |
||
22 | |||
23 | public function sendTemplateSms($tempId, $to, array $data) |
||
24 | { |
||
25 | $sendUrl = 'https://eco.taobao.com/router/rest'; |
||
26 | $params = [ |
||
27 | 'app_key' => $this->appKey, |
||
28 | 'v' => '2.0', |
||
29 | 'format' => 'json', |
||
30 | 'sign_method' => 'md5', |
||
31 | 'method' => 'alibaba.aliqin.fc.sms.num.send', |
||
32 | 'timestamp' => date('Y-m-d H:i:s'), |
||
33 | 'sms_type' => 'normal', |
||
34 | 'sms_free_sign_name' => $this->smsFreeSignName, |
||
35 | 'sms_param' => json_encode($data), |
||
36 | 'rec_num' => $to, |
||
37 | 'sms_template_code' => $tempId, |
||
38 | ]; |
||
39 | $params['sign'] = $this->generateSign($params); |
||
40 | $result = $this->curl($sendUrl, $params, true); |
||
41 | $this->genResult($result, 'alibaba_aliqin_fc_sms_num_send_response'); |
||
42 | } |
||
43 | |||
44 | public function voiceVerify($to, $code) |
||
48 | |||
49 | public function genResult($result, $callbackName) |
||
50 | { |
||
51 | if ($result['response']) { |
||
52 | $result = json_decode($result['response'], true); |
||
53 | if (isset($result[$callbackName]['result']) && $result[$callbackName]['result']['err_code'] == '0') { |
||
54 | $this->result['success'] = true; |
||
55 | return; |
||
56 | } elseif (isset($result['error_response'])) { |
||
57 | $this->result['info'] = $result['error_response']['msg'] . '|sub_msg:' . $result['error_response']['sub_msg'] . '|result:' . json_encode($result ?: ''); |
||
58 | $this->result['code'] = $result['error_response']['code'] . '_' . $result['error_response']['sub_code']; |
||
59 | return; |
||
60 | } |
||
61 | } |
||
62 | $this->result['info'] = '请求失败'; |
||
63 | } |
||
64 | |||
65 | protected function generateSign($params) |
||
80 | } |
||
81 |