Browse Source

添加发短信类

刘桂岩 4 năm trước cách đây
mục cha
commit
256f0971c9
1 tập tin đã thay đổi với 44 bổ sung0 xóa
  1. 44 0
      application/common/library/CMCC.php

+ 44 - 0
application/common/library/CMCC.php

@@ -0,0 +1,44 @@
+<?php
+
+
+namespace app\common\library;
+
+
+class CMCC {
+    public static $url = 'http://10.10.28.29:5011/sms/send/sync';
+
+    public static function sms($phone,$code)
+    {
+        $data = [];
+        $data['mobiles'] = $phone;
+        $data['params'] = $code;
+        $data['templateId'] = 'fa94e277027043f4b60b1c1758ca9f17';
+        // $data['addSerial'] = '';
+        $url = self::$url;
+        $return = self::http_post_json($url,json_encode($data,true));
+        var_dump($return);
+        return $return;
+    }
+
+    public static function http_post_json($url, $jsonStr)
+    {
+        $ch = curl_init();
+        curl_setopt($ch, CURLOPT_POST, 1);
+        curl_setopt($ch, CURLOPT_URL, $url);
+        curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonStr);
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
+                'Content-Type: application/json; charset=utf-8',
+                'Content-Length: ' . strlen($jsonStr)
+            )
+        );
+        $response = curl_exec($ch);
+        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+        curl_close($ch);
+        return array($httpCode, $response);
+    }
+    
+    
+}
+
+