<sub id="91vpp"></sub>
    <address id="91vpp"><listing id="91vpp"></listing></address>

                <form id="91vpp"></form>


                      待發短信

                      在線客服
                      產品支持 短信寶客服
                      合作渠道 渠道合作
                      服務咨詢

                      4001-021-502

                      工作時間

                      9:00-21:00

                      微擎模塊華旭在線考試新增短信寶短信接口

                      微擎是一款免費開源的公眾平臺管理系統,基于web2.0技術架構,他有很多的擴展模塊,二次開發也非常方便,智慧送水是微擎應用市場針對考試管理的一套應用模塊,小編對他還是了解, 今天小編就以替換短信接口為例告訴大家如何進行二次開發,我們講解的是V2.19.5版本,使用的短信接口是我們短信寶短信群發平臺的接口,我們短信寶短信群發平臺非常穩定,發送速度快,注冊就送測試短信,推薦大家使用。
                      1:打開項目:online_testapp\template\config.html 新增短信寶頁面

                      1
                      2
                      3
                      4
                      5
                      6
                      7
                      8
                      9
                      10
                      11
                      12
                      13
                      14
                      15
                      16
                      17
                      18
                      19
                      20
                      21
                      22
                      23
                      24
                      25
                      26
                      27
                      28
                      29
                      30
                      31
                      32
                      33
                      34
                      35
                      36
                      37
                      38
                      39
                      40
                      41
                      42
                      43
                      44
                      45
                      46
                      47
                      48
                      49
                      50
                      51
                      52
                      53
                      54
                      55
                      56
                      57
                      58
                      59
                      60
                      61
                      62
                      63
                      64
                      <div class="panel-heading">
                          <strong style="font-size:16px;">短信寶短信平臺接口設置</strong>
                          <p style="color:#666666;">請正確填寫相關參數,如果還沒有請 <a href=" target="_blank" style="color:#0066FF;">點擊此處</a> 申請。</p>
                      </div>
                      <div class="panel-body">
                       
                          <div class="form-group">
                              <label class="col-xs-2 control-label">短信驗證碼登陸</label>
                              <div class="col-xs-9">
                                  <p class="form-control-static">
                                      <input type="radio" name="sms_login" value="1" {if $config['sms_login'] == 1}checked{/if}/>&nbsp;開啟&nbsp;&nbsp;&nbsp;&nbsp;
                                      <input type="radio" name="sms_login" value="0" {if $config['sms_login'] != 1}checked{/if}/>&nbsp;關閉
                                  </p>
                                  <p class="form-control-static">
                                      短信接口開啟時有效
                                  </p>
                              </div>
                          </div>
                       
                          <div class="form-group">
                              <label class="col-xs-2 control-label">短信接口</label>
                              <div class="col-xs-9">
                                  <p class="form-control-static">
                                      <input type="radio" name="sms_open" value="1" {if $config['sms_open'] == 1}checked{/if}/>&nbsp;開啟&nbsp;&nbsp;&nbsp;&nbsp;
                                      <input type="radio" name="sms_open" value="0" {if $config['sms_open'] != 1}checked{/if}/>&nbsp;關閉
                                  </p>
                              </div>
                          </div>
                       
                          <div class="form-group">
                              <label class="col-xs-2 control-label">短信寶賬號</label>
                              <div class="col-xs-9" >
                                  <input class="form-control" name="sms_name" type="text" value="{$config['sms_name']}" style="width:300px;">
                              </div>
                          </div>
                       
                          <div class="form-group">
                              <label class="col-xs-2 control-label">短信寶密碼</label>
                              <div class="col-xs-9" >
                                  <input class="form-control" name="sms_password" type="password" value="{$config['sms_password']}" style="width:300px;">
                              </div>
                          </div>
                       
                          <div class="form-group">
                              <label class="col-xs-2 control-label">短信簽名</label>
                              <div class="col-xs-9" >
                                  <input class="form-control" name="sms_signsame" type="text" value="{$config['sms_signsame']}" style="width:300px;">
                              </div>
                          </div>
                       
                          <div class="form-group">
                              <label class="col-xs-2 control-label">短信模板</label>
                              <div class="col-xs-9" >
                                  <input class="form-control" name="sms_templatecode" type="text" value="{$config['sms_templatecode']}" style="width:300px;">
                              </div>
                          </div>
                       
                          <div class="form-group">
                              <label class="col-xs-2 control-label">驗證碼模版內容樣版</label>
                              <div class="col-xs-9" >
                                  <input class="form-control" id="reply-add-text" type="text" value="您的驗證碼為:${code}" style="width:300px; background-color:#E7E7E7;">
                              </div>
                          </div>
                      </div>

                      2:打開項目:addons\online_testapp\inc\mobile\sms.inc.php 修改大概30行代碼

                      1
                      2
                      3
                      4
                      5
                      6
                      7
                      8
                      9
                      10
                      11
                      $helper = new SignatureHelper();
                      //短信寶設置
                      $get = $helper->smsbao($accessKeyId, $accessKeySecret, $params);
                      if ($get["code"] == "0") {
                          $_SESSION["mobile"] = $mobile;
                          $_SESSION["mobile_code"] = $mobile_code;
                          echo "請求成功";
                      else {
                          echo $get["msg"];
                      }
                      exit;

                      3:打開項目:addons\online_testapp\class\signature_helper.class.php 修改發送短信函數

                      1
                      2
                      3
                      4
                      5
                      6
                      7
                      8
                      9
                      10
                      11
                      12
                      13
                      14
                      15
                      16
                      17
                      18
                      19
                      20
                      21
                      22
                      23
                      24
                      25
                      26
                      27
                      28
                      29
                      30
                      31
                      32
                      33
                      34
                      35
                      36
                      37
                      38
                      39
                      40
                      41
                      42
                      43
                      44
                      45
                      46
                      47
                      48
                      49
                      50
                      51
                      52
                      53
                      54
                      55
                      56
                      57
                      58
                      59
                      60
                      61
                      62
                      63
                      64
                      65
                      66
                      67
                      68
                      69
                      70
                      71
                      72
                      73
                      74
                      75
                      76
                      class SignatureHelper
                      {
                          public function request($accessKeyId, $accessKeySecret, $domain, $params, $security = false)
                          {
                              $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 .= "&" . $this->encode($key) . "=" . $this->encode($value);
                              }
                              $stringToSign = "GET&%2F&" . $this->encode(substr($sortedQueryStringTmp, 1));
                              $sign = base64_encode(hash_hmac("sha1", $stringToSign, $accessKeySecret . "&"true));
                              $signature = $this->encode($sign);
                              $url = ($security ? "https" "http") . "://{$domain}/?Signature={$signature}{$sortedQueryStringTmp}";
                              try {
                                  $content = $this->fetchContent($url);
                                  return json_decode($content);
                              catch (\Exception $e) {
                                  return false;
                              }
                          }
                          private function encode($str)
                          {
                              $res = urlencode($str);
                              $res = preg_replace("/\\+/""%20", $res);
                              $res = preg_replace("/\\*/""%2A", $res);
                              $res = preg_replace("/%7E/""~", $res);
                              return $res;
                          }
                          private 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;
                          }
                          public function smsbao($smsuser,$smspwd,$params){
                              $statusStr = array(
                                  "0" => "短信發送成功",
                                  "-1" => "參數不全",
                                  "-2" => "服務器空間不支持,請確認支持curl或者fsocket,聯系您的空間商解決或者更換空間!",
                                  "30" => "密碼錯誤",
                                  "40" => "賬號不存在",
                                  "41" => "余額不足",
                                  "42" => "帳戶已過期",
                                  "43" => "IP地址限制",
                                  "50" => "內容含有敏感詞"
                              );
                              $smsapi = ';
                              $user = $smsuser; //短信平臺帳號
                              $pass = md5($smspwd); //短信平臺密碼
                              $content = '【'.$params["SignName"].'】'.str_replace('${code}',$params["TemplateParam"]['code'],$params["TemplateCode"]);//要發送的短信內容
                              $phone = $params["PhoneNumbers"];//要發送短信的手機號碼
                              $sendurl = $smsapi."sms?u=".$user."&p=".$pass."&m=".$phone."&c=".urlencode($content);
                              try {
                                  $result = $this->fetchContent($sendurl);
                                  return [
                                      'code'=>$result,
                                      'msg'=>$statusStr[$result]
                                  ];
                              catch (\Exception $e) {
                                  return false;
                              }
                          }
                      }

                      經過上面的替換,短信寶的短信平臺已經替換成功了,可以正常使用了。進行測試發送:

                      報備一下短信寶的VIP模板,這樣就可以走短信寶的優質通道了,即便遇到敏感文字我們都不會人工審核,短信內容3~5秒就可送達。

                      另外:我們已經開發好完整的微擎模塊華旭在線考試注冊模塊系統短信寶插件,點擊此鏈接?下載及查看安裝流程。

                      開源插件

                      最新更新

                      電商類

                      CMS類

                      微信類

                      文章標簽
                      亚洲欧洲美洲无码精品Va,久久免费看少妇高潮A片特黄网站,亚洲精品另类孕妇A片,久久免费看少妇高潮A片不卡农村