Browse Source

移动云短信,发送成功

lizhen_gitee 6 months ago
parent
commit
8b3679dadf
2 changed files with 40 additions and 5 deletions
  1. 9 4
      application/api/controller/Demo.php
  2. 31 1
      application/common/library/Sms.php

+ 9 - 4
application/api/controller/Demo.php

@@ -25,8 +25,9 @@ class Demo extends Api
     //移动云短信
     public function yidong_sms(){
         $mobile = '18560505277';
-        $content = '【淮安达富居家养老】您的短信验证码是1234,五分钟内有效';
-        $url = 'https://112.35.1.155:443/sms/submit';
+        $code = '1234';
+        $content = '您的短信验证码是'.$code.',本验证码五分钟内有效,请勿泄露';
+        $url = 'https://112.35.10.201:28888/sms/submit';
         $data = [
             'ecName' => '江苏达富居家养老健康管理有限公司',
             'apId' => 'dafuhttps',
@@ -43,9 +44,13 @@ class Demo extends Api
 
         $header = ["Content-Type:application/json;charset=UTF-8"];
         $rs = curl_post($url,base64_encode(json_encode($data)),$header);
-        dump($rs);
+dump($rs);
+        $rs = json_decode($rs,true);
+        if(isset($rs['success']) && $rs['success'] == true){
+            return true;
+        }
 
-        $secretKey = '&YY4vrJb';
+        return false;
     }
 
     /**

+ 31 - 1
application/common/library/Sms.php

@@ -61,7 +61,7 @@ class Sms
         $params['mobile'] = $mobile;
         $params['code'] = $code;
 
-        $result = self::smsSend($params);
+        $result = self::yidong_sms($mobile,$code);
 
         if (!$result) {
             $sms->delete();
@@ -70,6 +70,36 @@ class Sms
         return true;
     }
 
+    //移动云短信https://mas.10086.cn/login
+    public static function yidong_sms($mobile,$code){
+
+        $content = '您的短信验证码是'.$code.',本验证码五分钟内有效,请勿泄露';
+        $url = 'https://112.35.10.201:28888/sms/submit';
+        $data = [
+            'ecName' => '江苏达富居家养老健康管理有限公司',
+            'apId' => 'dafuhttps',
+            'secretKey' => '&YY4vrJb',
+            'mobiles' => $mobile,
+            'content' => $content,
+            'sign' => 'YV61594FE',
+            'addSerial' => '',
+        ];
+
+        $mac = md5(join('',$data));
+        $data['mac'] = $mac;
+        unset($data['secretKey']);
+
+        $header = ["Content-Type:application/json;charset=UTF-8"];
+        $rs = curl_post($url,base64_encode(json_encode($data)),$header);
+
+        $rs = json_decode($rs,true);
+        if(isset($rs['success']) && $rs['success'] == true){
+            return true;
+        }
+
+        return false;
+    }
+
     /**
      * 短信发送行为
      * @param array $params 必须包含mobile,event,code