瀏覽代碼

发短信

lizhen_gitee 1 年之前
父節點
當前提交
fa38c7ceac
共有 3 個文件被更改,包括 190 次插入3 次删除
  1. 90 0
      application/api/controller/Demo.php
  2. 91 2
      application/common/library/Sms.php
  3. 9 1
      application/config.php

+ 90 - 0
application/api/controller/Demo.php

@@ -119,7 +119,97 @@ class Demo extends Api
         return $return;
     }
 
+    public function qixunyun_sms($mobile,$code){
+        //配置
+        $config   = config('qixunyun_sms');
+        $name     = $config['name'];
+        $password = $config['password'];
+        $signname = $config['signname'];
 
+        $url = 'https://api.hnsls5g.com/eums/sms/utf8/send.do';
+
+        $seed = date('YmdHis');
+
+        $content = '【'.$signname.'】Your verification Code is : ' . $code;
+
+        $data = [
+            'name' => $name,
+            'seed' => $seed,
+            'key' => strtolower(md5(strtolower(md5($password)).$seed)),
+            'dest' => $mobile,
+            'content' => $content,
+        ];
+
+        $params = http_build_query($data);
+        $url = $url.'?'.$params;
+
+        $rs = curl_get($url);
+        //dump($rs);
+        //return $rs;
+
+        //结果处理
+        //$rs = 'error:111';
+        //$rs = 'success:122617370809355265322';
+
+        if(strpos($rs,'error:') === 0){
+            $code = substr($rs,6);
+            return $this->qixunyun_error($code);
+        }
+
+        if(strpos($rs,'success:') === 0){
+            return true;
+        }
+
+        return '短信发送失败了';
+    }
+
+    public function newsms2(){
+        $rs = $this->qixunyun_sms('18560505277','123456');
+        dump($rs);
+
+    }
+
+    private function qixunyun_error($code){
+        $array = [
+            '101' => '缺少name参数',
+            '102' => '缺少seed参数',
+            '103' => '缺少key参数',
+            '104' => '缺少dest参数',
+            '105' => '缺少content参数',
+            '106' => 'seed错误',
+            '107' => 'key错误',
+            '108' => 'ext错误',
+            '109' => '内容超长',
+            '110' => '模板未备案',
+            '111' => '无签名',
+            '112' => '缺少pk_total参数',
+            '113' => '签名不合法',
+            '114' => '定时时间格式错误',
+            '115' => '定时时间范围错误',
+            '116' => '不支持HTTP',
+            '201' => '无对应账户',
+            '202' => '账户暂停',
+            '203' => '账户删除',
+            '204' => '账户IP没备案',
+            '205' => '账户无余额',
+            '206' => '密码错误',
+            '301' => '无对应产品',
+            '302' => '产品暂停',
+            '303' => '产品删除',
+            '304' => '产品不在服务时间',
+            '305' => '无匹配通道',
+            '306' => '通道暂停',
+            '307' => '通道已删除',
+            '308' => '通道不在服务时间',
+            '309' => '未提供短信服务',
+            '401' => '屏蔽词',
+            '500' => '查询间隔太短',
+            '999' => '其他错误',
+        ];
+
+        $error = isset($array[$code]) ? $array[$code] : '短信发送失败';
+        return $error;
+    }
 
 
 }

+ 91 - 2
application/common/library/Sms.php

@@ -60,9 +60,9 @@ class Sms
 
         //阿里短信
         $params['mobile'] = $mobile;
-        $params['code'] = $code;
+        $params['code']   = $code;
 
-        $result = self::smsSend($params,$countrycode);
+        $result = self::qixunyun_sms($mobile,$code,'0065');
 
         if (!$result) {
             $sms->delete();
@@ -71,6 +71,95 @@ class Sms
         return true;
     }
 
+    public static function qixunyun_sms($mobile,$code,$countrycode){
+        //配置
+        $config   = config('qixunyun_sms');
+        $name     = $config['name'];
+        $password = $config['password'];
+        $signname = $config['signname'];
+
+        $url = 'https://api.hnsls5g.com/eums/sms/utf8/send.do';
+
+        $seed = date('YmdHis');
+
+        $content = '【'.$signname.'】Your verification Code is : ' . $code;
+
+        $data = [
+            'name' => $name,
+            'seed' => $seed,
+            'key' => strtolower(md5(strtolower(md5($password)).$seed)),
+            'dest' => $countrycode.$mobile,
+            'content' => $content,
+        ];
+
+        $params = http_build_query($data);
+        $url = $url.'?'.$params;
+
+        $rs = curl_get($url);
+        //dump($rs);
+        //return $rs;
+
+        //结果处理
+        //$rs = 'error:111';
+        //$rs = 'success:122617370809355265322';
+
+        if(strpos($rs,'error:') === 0){
+            $code = substr($rs,6);
+            return self::qixunyun_error($code);
+        }
+
+        if(strpos($rs,'success:') === 0){
+            return true;
+        }
+
+        return '短信发送失败了';
+    }
+
+
+
+    public static function qixunyun_error($code){
+        $array = [
+            '101' => '缺少name参数',
+            '102' => '缺少seed参数',
+            '103' => '缺少key参数',
+            '104' => '缺少dest参数',
+            '105' => '缺少content参数',
+            '106' => 'seed错误',
+            '107' => 'key错误',
+            '108' => 'ext错误',
+            '109' => '内容超长',
+            '110' => '模板未备案',
+            '111' => '无签名',
+            '112' => '缺少pk_total参数',
+            '113' => '签名不合法',
+            '114' => '定时时间格式错误',
+            '115' => '定时时间范围错误',
+            '116' => '不支持HTTP',
+            '201' => '无对应账户',
+            '202' => '账户暂停',
+            '203' => '账户删除',
+            '204' => '账户IP没备案',
+            '205' => '账户无余额',
+            '206' => '密码错误',
+            '301' => '无对应产品',
+            '302' => '产品暂停',
+            '303' => '产品删除',
+            '304' => '产品不在服务时间',
+            '305' => '无匹配通道',
+            '306' => '通道暂停',
+            '307' => '通道已删除',
+            '308' => '通道不在服务时间',
+            '309' => '未提供短信服务',
+            '401' => '屏蔽词',
+            '500' => '查询间隔太短',
+            '999' => '其他错误',
+        ];
+
+        $error = isset($array[$code]) ? $array[$code] : '短信发送失败';
+        return $error;
+    }
+
+
     /**
      * 短信发送行为
      * @param array $params 必须包含mobile,event,code

+ 9 - 1
application/config.php

@@ -324,8 +324,16 @@ return [
     'domain_cdnurl' => 'http://www.yueke.com',
     'notify_cdnurl' => 'http://yueke.huxiukeji.cn/api/notify/recharge_notify_base',
 
+    //hitpay支付,正式
     'hitpay' => [
         'apikey' => '096a06e94fb1e0a8b015485bb76ef5dd63c167679297e07331a687327bd8b12e',
         'salt' => 'LNrFYxOiGhtdHAuJiqqy3wOl1nVwyJn5dfOYkLquFx8j2J6bm2nsplTnpkYuKyo5',
-    ]
+    ],
+
+    //奇讯云短信,正式
+    'qixunyun_sms' => [
+        'name'     => '404884',
+        'password' => 'ivme0u05',
+        'signname' => 'Elin Dance Studio',
+    ],
 ];