aiyou 4 年之前
父节点
当前提交
adb32c78ea
共有 2 个文件被更改,包括 23 次插入23 次删除
  1. 19 19
      application/api/controller/Member.php
  2. 4 4
      extend/aliyun/api_demo/SmsDemo.php

+ 19 - 19
application/api/controller/Member.php

@@ -138,26 +138,12 @@ class Member extends Api
         }
 
         $code = rand(1000, 9999);
-//        $Sms = new SmsDemo();
-//        $send = $Sms->sendSms($mobile, $code);
-//        if ($send->Message == 'OK') {
-//            $log = ['code' => $code,
-//                'mobile' => $mobile,
-//                'scene' =>$scene,
-//                'time' => datetime(time())
-//            ];
-//            $addLog = CodeModel::create($log);
-//            if ($addLog) {
-//                $this->result('验证码已发送', [], 1);
-//            } else {
-//                $this->result('验证码发送失败');
-//            }
-//        } else {
-//            $this->result('验证码发送失败');
-//        }
-        $log = ['code' => '1234',
+        $Sms = new SmsDemo();
+        $send = $Sms->sendSms($mobile, $code);
+        if ($send->Message == 'OK') {
+            $log = ['code' => $code,
                 'mobile' => $mobile,
-                 'scene' =>$scene,
+                'scene' =>$scene,
                 'time' => datetime(time())
             ];
             $addLog = CodeModel::create($log);
@@ -166,6 +152,20 @@ class Member extends Api
             } else {
                 $this->result('验证码发送失败');
             }
+        } else {
+            $this->result('验证码发送失败');
+        }
+//        $log = ['code' => '1234',
+//                'mobile' => $mobile,
+//                 'scene' =>$scene,
+//                'time' => datetime(time())
+//            ];
+//            $addLog = CodeModel::create($log);
+//            if ($addLog) {
+//                $this->result('验证码已发送', [], 1);
+//            } else {
+//                $this->result('验证码发送失败');
+//            }
 
     }
 

+ 4 - 4
extend/aliyun/api_demo/SmsDemo.php

@@ -40,9 +40,9 @@ class SmsDemo
         $domain = "dysmsapi.aliyuncs.com";
 
         // TODO 此处需要替换成开发者自己的AK (https://ak-console.aliyun.com/)
-        $accessKeyId = "LTAI4Fqgvir6UMbpNZTtKCkZ"; // AccessKeyId
+        $accessKeyId = "LTAI4GErKs1vzkf8inK48iGA"; // AccessKeyId
 
-        $accessKeySecret = "jnDEzruWbU4J4diewypWXBYBSmFtoD"; // AccessKeySecret
+        $accessKeySecret = "DhZzsWgmVGKUzp38OJeLMa8SZPVQmH"; // AccessKeySecret
 
         // 暂时不支持多Region
         $region = "cn-hangzhou";
@@ -81,10 +81,10 @@ class SmsDemo
         $request->setPhoneNumbers($mobile);
 
         // 必填,设置签名名称,应严格按"签名名称"填写,请参考: https://dysms.console.aliyun.com/dysms.htm#/develop/sign
-        $request->setSignName("确认键课堂");
+        $request->setSignName("新天物业");
 
         // 必填,设置模板CODE,应严格按"模板CODE"填写, 请参考: https://dysms.console.aliyun.com/dysms.htm#/develop/template
-        $request->setTemplateCode("SMS_183266908");
+        $request->setTemplateCode("SMS_207945698");
 
         // 可选,设置模板参数, 假如模板中存在变量需要替换则为必填项
         $request->setTemplateParam(json_encode(array(  // 短信模板中字段的值