12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?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));
- 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);
- }
-
-
- }
|