|
@@ -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);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|