<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                ~~~ <?php /** * 阿里云短信驗證碼發送類 * @author Administrator * */ class Sms { // 保存錯誤信息 public $error; // Access Key ID private $accessKeyId = ''; // Access Access Key Secret private $accessKeySecret = ''; // 簽名 private $signName = ''; // 模版ID private $templateCode = ''; public function __construct($cofig = array()) { /* * 通過參數傳遞 * $cofig = array ( 'accessKeyId' => 'xxxxxxxxxxxx', 'accessKeySecret' => 'xxxxxxxxxxxxxxxx', 'signName' => 'xxxxxxxxxx', 'templateCode' => 'xxxxxxxxxxx' );*/ // 配置參數 $this->accessKeyId = $cofig ['accessKeyId']; $this->accessKeySecret = $cofig ['accessKeySecret']; $this->signName = $cofig ['signName']; $this->templateCode = $cofig ['templateCode']; } private function percentEncode($string) { $string = urlencode ( $string ); $string = preg_replace ( '/\+/', '%20', $string ); $string = preg_replace ( '/\*/', '%2A', $string ); $string = preg_replace ( '/%7E/', '~', $string ); return $string; } /** * 簽名 * * @param unknown $parameters * @param unknown $accessKeySecret * @return string */ private function computeSignature($parameters, $accessKeySecret) { ksort ( $parameters ); $canonicalizedQueryString = ''; foreach ( $parameters as $key => $value ) { $canonicalizedQueryString .= '&' . $this->percentEncode ( $key ) . '=' . $this->percentEncode ( $value ); } $stringToSign = 'GET&%2F&' . $this->percentencode ( substr ( $canonicalizedQueryString, 1 ) ); $signature = base64_encode ( hash_hmac ( 'sha1', $stringToSign, $accessKeySecret . '&', true ) ); return $signature; } /** * @param unknown $mobile * @param unknown $verify_code * */ public function send_verify($mobile, $verify_code) { $params = array ( //此處作了修改 'SignName' => $this->signName, 'Format' => 'JSON', 'Version' => '2017-05-25', 'AccessKeyId' => $this->accessKeyId, 'SignatureVersion' => '1.0', 'SignatureMethod' => 'HMAC-SHA1', 'SignatureNonce' => uniqid (), 'Timestamp' => gmdate ( 'Y-m-d\TH:i:s\Z' ), 'Action' => 'SendSms', 'TemplateCode' => $this->templateCode, 'PhoneNumbers' => $mobile, 'TemplateParam' => '{"code":"' . $verify_code . '"}'//更換為自己的實際模版 ); //var_dump($params);die; // 計算簽名并把簽名結果加入請求參數 $params ['Signature'] = $this->computeSignature ( $params, $this->accessKeySecret ); // 發送請求(此處作了修改) //$url = 'https://sms.aliyuncs.com/?' . http_build_query ( $params ); $url = 'http://dysmsapi.aliyuncs.com/?' . http_build_query ( $params ); $ch = curl_init (); curl_setopt ( $ch, CURLOPT_URL, $url ); curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, FALSE ); curl_setopt ( $ch, CURLOPT_SSL_VERIFYHOST, FALSE ); curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt ( $ch, CURLOPT_TIMEOUT, 10 ); $result = curl_exec ( $ch ); curl_close ( $ch ); $result = json_decode ( $result, true ); //var_dump($result);die; if ( $result ['Code'] != 'OK') { $this->error = $this->getErrorMessage ( $result ['Code'] ); return false; } return true; } /** * 獲取詳細錯誤信息 * * @param unknown $status */ public function getErrorMessage($status) { // 阿里云的短信 亂八七糟的(其實是用的阿里大于) // https://api.alidayu.com/doc2/apiDetail?spm=a3142.7629140.1.19.SmdYoA&apiId=25450 $message = array ( 'isv.BUSINESS_LIMIT_CONTROL' => '短信發送頻率超限', 'isv.DAY_LIMIT_CONTROL' => '已經達到您在控制臺設置的短信日發送量限額值', 'isv.SMS_CONTENT_ILLEGAL' => '短信內容包含禁止發送內容,請修改短信文案', 'isv.SMS_SIGN_ILLEGAL' => '簽名禁止使用,請在短信服務控制臺中申請符合規定的簽名', 'isp.RAM_PERMISSION_DENY' => 'RAM權限不足。,請為當前使用的AK對應子賬號進行授權:AliyunDysmsFullAccess(管理權限)', 'isv.OUT_OF_SERVICE' => '余額不足。余額不足時,套餐包中即使有短信額度也無法發送短信', 'isv.PRODUCT_UN_SUBSCRIPT' => '未開通云通信產品的阿里云客戶', 'isv.PRODUCT_UNSUBSCRIBE' => '產品未開通', 'isv.ACCOUNT_NOT_EXISTS' => '賬戶不存在,使用了錯誤的賬戶名稱或AK', 'isv.ACCOUNT_ABNORMAL' => '賬戶異常', 'isv.SMS_TEMPLATE_ILLEGAL' => '短信模板不存在,或未經審核通過', 'isv.SMS_SIGNATURE_ILLEGAL' => '簽名不存在,或未經審核通過', 'isv.INVALID_PARAMETERS' => '參數格式不正確', 'isv.MOBILE_NUMBER_ILLEGAL' => '機號碼格式錯誤', 'isv.MOBILE_COUNT_OVER_LIMIT' => '參數PhoneNumbers中指定的手機號碼數量超出限制', 'isv.TEMPLATE_MISSING_PARAMETERS' => '模版缺少變量', 'isv.BLACK_KEY_CONTROL_LIMIT' => '黑名單管控', 'isv.PARAM_LENGTH_LIMIT' => '參數超出長度限制', 'isv.PARAM_NOT_SUPPORT_URL' => '不支持URL', 'isv.AMOUNT_NOT_ENOUGH' => '賬戶余額不足', 'SignatureDoesNotMatch' => '簽名(Signature)加密錯誤', ); if (isset ( $message [$status] )) { return $message [$status]; } return $status; } } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看