APP、網站等註冊、登入、改密等發送驗證碼簡訊的接入流程

來源:互聯網
上載者:User

標籤:PHP   簡訊驗證碼   APP   註冊登入   

1.登入 https://zz.253.com/site/login.html
2.擷取介面API帳號,密碼:選擇任意產品>啟用>企業認證(上傳公司營業執照)
3.申請簽名(以公司簡稱或縮寫命名)備忘:平台申請簽名,API介面加上申請簽名
4.模板申請(自訂編輯內容):選擇任意應用>短息編輯欄目{範本管理員}>添加簽名
4.sms_send_demo.php傳送簡訊
sms_queryBalance_demo.php查詢簡訊餘額
備忘:申請模板可達到簡訊免審作用

常見問題
1.相同號碼一天有10條限制(可根據業務需求進行調整)
2.介面帳號(使用API帳號,密碼 並非登入管理後台帳號,密碼)

狀態報表接入流程:
1.配置一個外網可以訪問的URL來接受創藍伺服器的非同步推送
2.參考receive.php

主要代碼:
<?php
header("Content-type:text/html; charset=UTF-8");

class ChuanglanSmsApi {

    //傳送簡訊的介面地址    const API_SEND_URL=‘http://sms.253.com/msg/send?‘;    //查詢餘額的介面地址    const API_BALANCE_QUERY_URL=‘http://sms.253.com/msg/balance?‘;    const API_ACCOUNT=‘*******‘;//簡訊帳號從 https://zz.253.com/site/login.html 裡面擷取。    const API_PASSWORD=‘*******‘;//簡訊密碼從 from https://zz.253.com/site/login.html 裡面擷取。    /**     * 傳送簡訊需要的介面參數     *     * @param string $mobile                 手機號碼     * @param string $msg                         想要發送的簡訊內容     * @param string $needstatus         是否需要狀態報表 ‘1‘為需要 ‘0‘位不需要。     */    public function sendSMS( $mobile, $msg, $needstatus = 1) {            //傳送簡訊的介面參數            $postArr = array (                                      ‘un‘ => self::API_ACCOUNT,                                      ‘pw‘ => self::API_PASSWORD,                                      ‘msg‘ => $msg,                                      ‘phone‘ => $mobile,                                      ‘rd‘ => $needstatus                 );            $result = $this->curlPost( self::API_SEND_URL , $postArr);            return $result;    }    /**     *      *     *  查詢餘額     */    public function queryBalance() {            // 查詢介面參數            $postArr = array (                       ‘un‘ => self::API_ACCOUNT,                      ‘pw‘ => self::API_PASSWORD,            );            $result = $this->curlPost(self::API_BALANCE_QUERY_URL, $postArr);            return $result;    }    /**     * 處理介面傳回值     *      */    public function execResult($result){            $result=preg_split("/[,\r\n]/",$result);            return $result;    }    /**     * @param string $url       * @param array $postFields      * @return mixed     */    private function curlPost($url,$postFields){            $postFields = http_build_query($postFields);             if(function_exists(‘curl_init‘)){                    $ch = curl_init ();                    curl_setopt ( $ch, CURLOPT_POST, 1 );                    curl_setopt ( $ch, CURLOPT_HEADER, 0 );                    curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );                    curl_setopt ( $ch, CURLOPT_URL, $url );                    curl_setopt ( $ch, CURLOPT_POSTFIELDS, $postFields );                    $result = curl_exec ( $ch );                    if(curl_errno($ch))                    {                            return ‘Curl error: ‘ . curl_error($ch);                    }                    curl_close ( $ch );            }elseif(function_exists(‘file_get_contents‘)){                    $result=file_get_contents($url.$postFields);            }            return $result;    }    //魔術擷取    public function __get($name){            return $this->$name;    }    //魔術設定    public function __set($name,$value){            $this->$name=$value;    }

}
?>

APP、網站等註冊、登入、改密等發送驗證碼簡訊的接入流程

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.