| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 | 
							- <?php
 
- /***
 
-  * User: jun_hy
 
-  * Date: 2022/7/6
 
-  * Time: 15:41
 
-  */
 
- function sendSmsali($phone,$template_body,$from)
 
- {
 
-     $params = array();
 
-     $params["To"] = $phone;
 
-     $params["From"] = $from;
 
-     $params["Message"] = $template_body;
 
-     $params['Type'] = "NOTIFY";
 
-     $content = request(
 
-         "dysmsapi.aliyuncs.com",
 
-         array_merge($params, array(
 
-             "RegionId" => "cn-hangzhou",
 
-             "Action" => "SendMessageToGlobe",
 
-             "Version" => "2017-05-25",
 
-         ))
 
-     );
 
-     if ($content->Code == 'OK') {
 
-         return $content;
 
-     } else {
 
-         return false;
 
-     }
 
- }
 
- /**
 
-  * 查询发送短信状态
 
-  * mobile            手机号码
 
-  * TemplateParam    参数数组
 
-  * TemplateCode        模版CODE
 
-  */
 
- function QuerySendDetails($phone,$bizId,$times)
 
- {
 
-     $params = array();
 
-     $params["PhoneNumber"] = $phone;
 
-     $params['BizId'] =  $bizId;
 
-     $params['SendDate'] =  $times;
 
-     $params['PageSize'] =  10;
 
-     $params['CurrentPage'] =  1;
 
-     $content = $this->request(
 
-         "dysmsapi.aliyuncs.com",
 
-         array_merge($params, array(
 
-             "RegionId" => "cn-hangzhou",
 
-             "Action" => "QuerySendDetails",
 
-             "Version" => "2017-05-25",
 
-         ))
 
-     );
 
-     if ($content->Code == 'OK') {
 
-         return $content->SmsSendDetailDTOs;
 
-     } else {
 
-         return false;
 
-     }
 
- }
 
-  function request($domain, $params, $security = false)
 
- {
 
-     $accessKeyId ='LTAI5tD31ApgijqwnZthM9SH';
 
-     $accessKeySecret = 'NsEwR56E7qB8hBLBxkUqaZe4AahEyd';
 
-     $apiParams = array_merge(array(
 
-         "SignatureMethod" => "HMAC-SHA1",
 
-         "SignatureNonce" => uniqid(mt_rand(0, 0xffff), true),
 
-         "SignatureVersion" => "1.0",
 
-         "AccessKeyId" => $accessKeyId,
 
-         "Timestamp" => gmdate("Y-m-d\TH:i:s\Z"),
 
-         "Format" => "JSON",
 
-     ), $params);
 
-     ksort($apiParams);
 
-     $sortedQueryStringTmp = "";
 
-     foreach ($apiParams as $key => $value) {
 
-         $sortedQueryStringTmp .= "&" . encode($key) . "=" . encode($value);
 
-     }
 
-     $stringToSign = "GET&%2F&" . encode(substr($sortedQueryStringTmp, 1));
 
-     $sign = base64_encode(hash_hmac("sha1", $stringToSign, $accessKeySecret . "&", true));
 
-     $signature = encode($sign);
 
-     $url = ($security ? 'https' : 'http') . "://{$domain}/?Signature={$signature}{$sortedQueryStringTmp}";
 
-     try {
 
-         $content = fetchContent($url);
 
-         return json_decode($content);
 
-     } catch (\Exception $e) {
 
-         return false;
 
-     }
 
- }
 
-  function encode($str)
 
- {
 
-     $res = urlencode($str);
 
-     $res = preg_replace("/\+/", "%20", $res);
 
-     $res = preg_replace("/\*/", "%2A", $res);
 
-     $res = preg_replace("/%7E/", "~", $res);
 
-     return $res;
 
- }
 
-  function fetchContent($url)
 
- {
 
-     $ch = curl_init();
 
-     curl_setopt($ch, CURLOPT_URL, $url);
 
-     curl_setopt($ch, CURLOPT_TIMEOUT, 5);
 
-     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 
-     curl_setopt($ch, CURLOPT_HTTPHEADER, array(
 
-         "x-sdk-client" => "php/2.0.0"
 
-     ));
 
-     if (substr($url, 0, 5) == 'https') {
 
-         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
 
-         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
 
-     }
 
-     $rtn = curl_exec($ch);
 
-     if ($rtn === false) {
 
-         trigger_error("[CURL_" . curl_errno($ch) . "]: " . curl_error($ch), E_USER_ERROR);
 
-     }
 
-     curl_close($ch);
 
-     return $rtn;
 
- }
 
 
  |