中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》
  • 首頁 > 
  • 教程 > 
  • 開發技術 > 
  • php短信接口,免認證限制少的接口,手機短信,短信驗證碼

php短信接口,免認證限制少的接口,手機短信,短信驗證碼

發布時間:2020-07-01 23:48:19 來源:網絡 閱讀:618 作者:kewail飛飛 欄目:開發技術

下面介紹一下kewail的短信接口,鏈接:https://www.kewail.com/

// Works well with php5.3 and php5.6.

namespace Kewail\Sms;

require_once('SmsSenderUtil.php');

class SmsSingleSender {
var $url;
var $accesskey;
var $secretkey;
var $util;

function __construct($accesskey, $secretkey) {
    $this->url = "https://live.kewail.com/sms/v1/sendsinglesms";
    $this->accesskey =  $accesskey;
    $this->secretkey = $secretkey;
    $this->util = new SmsSenderUtil();
}

/**
 * 普通單發,明確指定內容,如果有多個簽名,請在內容中以【】的方式添加到信息內容中,否則系統將使用默認簽名
 * @param int $type 短信類型,0 為普通短信,1 營銷短信
 * @param string $nationCode 國家碼,如 86 為中國
 * @param string $phoneNumber 不帶國家碼的手機號
 * @param string $msg 信息內容,必須與申請的模板格式一致,否則將返回錯誤
 * @param string $extend 擴展碼,可填空串
 * @param string $ext 服務端原樣返回的參數,可填空串
 * @return string json string { "result": xxxxx, "errmsg": "xxxxxx" ... },被省略的內容參見協議文檔
 */
function send($type, $nationCode, $phoneNumber, $msg, $extend = "", $ext = "") {

/
請求包體
{
"tel": {
"nationcode": "86",
"mobile": "13788888888"
},
"type": 0,
"msg": "你的驗證碼是1234",
"sig": "fdba654e05bc0d15796713a1a1a2318c",
"time": 1479888540,
"extend": "",
"ext": ""
}
應答包體
{
"result": 0,
"errmsg": "OK",
"ext": "",
"sid": "xxxxxxx",
"fee": 1
}
/
$random = $this->util->getRandom();
$curTime = time();
$wholeUrl = $this->url . "?accesskey=" . $this->accesskey . "&random=" . $random;

    // 按照協議組織 post 包體
    $data = new \stdClass();
    $tel = new \stdClass();
    $tel->nationcode = "".$nationCode;
    $tel->mobile = "".$phoneNumber;

    $data->tel = $tel;
    $data->type = (int)$type;
    $data->msg = $msg;
    $data->sig = hash("sha256",
        "secretkey=".$this->secretkey."&random=".$random."&time=".$curTime."&mobile=".$phoneNumber, FALSE);
    $data->time = $curTime;
    $data->extend = $extend;
    $data->ext = $ext;
    return $this->util->sendCurlPost($wholeUrl, $data);
}

/**
 * 指定模板單發
 * @param string $nationCode 國家碼,如 86 為中國
 * @param string $phoneNumber 不帶國家碼的手機號
 * @param int $templId 模板 id
 * @param array $params 模板參數列表,如模板 {1}...{2}...{3},那么需要帶三個參數
 * @param string $sign 簽名,如果填空串,系統會使用默認簽名
 * @param string $extend 擴展碼,可填空串
 * @param string $ext 服務端原樣返回的參數,可填空串
 * @return string json string { "result": xxxxx, "errmsg": "xxxxxx"  ... },被省略的內容參見協議文檔
 */
function sendWithParam($nationCode, $phoneNumber, $templId = 0, $params, $sign = "", $extend = "", $ext = "") {

/
請求包體
{
"tel": {
"nationcode": "86",
"mobile": "13788888888"
},
"sign": "Kewail",
"tpl_id": 19,
"params": [
"驗證碼",
"1234",
"4"
],
"sig": "fdba654e05bc0d15796713a1a1a2318c",
"time": 1479888540,
"extend": "",
"ext": ""
}
應答包體
{
"result": 0,
"errmsg": "OK",
"ext": "",
"sid": "xxxxxxx",
"fee": 1
}
/
$random = $this->util->getRandom();
$curTime = time();
$wholeUrl = $this->url . "?sdkaccesskey=" . $this->accesskey . "&random=" . $random;

    // 按照協議組織 post 包體
    $data = new \stdClass();
    $tel = new \stdClass();
    $tel->nationcode = "".$nationCode;
    $tel->mobile = "".$phoneNumber;

    $data->tel = $tel;
    $data->sig = $this->util->calculateSigForTempl($this->secretkey, $random, $curTime, $phoneNumber);
    $data->tpl_id = $templId;
    $data->params = $params;
    $data->sign = $sign;
    $data->time = $curTime;
    $data->extend = $extend;
    $data->ext = $ext;
    return $this->util->sendCurlPost($wholeUrl, $data);
}

}

class SmsMultiSender {
var $url;
var $accesskey;
var $secretkey;
var $util;

function __construct($accesskey, $secretkey) {
    $this->url = "https://live.kewail.com/sms/v1/sendsinglesms";
    $this->accesskey =  $accesskey;
    $this->secretkey = $secretkey;
    $this->util = new SmsSenderUtil();
}

/**
 * 普通群發,明確指定內容,如果有多個簽名,請在內容中以【】的方式添加到信息內容中,否則系統將使用默認簽名
 * 【注意】海外短信無群發功能
 * @param int $type 短信類型,0 為普通短信,1 營銷短信
 * @param string $nationCode 國家碼,如 86 為中國
 * @param string $phoneNumbers 不帶國家碼的手機號列表
 * @param string $msg 信息內容,必須與申請的模板格式一致,否則將返回錯誤
 * @param string $extend 擴展碼,可填空串
 * @param string $ext 服務端原樣返回的參數,可填空串
 * @return string json string { "result": xxxxx, "errmsg": "xxxxxx" ... },被省略的內容參見協議文檔
 */
function send($type, $nationCode, $phoneNumbers, $msg, $extend = "", $ext = "") {

/
請求包體
{
"tel": [
{
"nationcode": "86",
"mobile": "13788888888"
},
{
"nationcode": "86",
"mobile": "13788888889"
}
],
"type": 0,
"msg": "你的驗證碼是1234",
"sig": "fdba654e05bc0d15796713a1a1a2318c",
"time": 1479888540,
"extend": "",
"ext": ""
}
應答包體
{
"result": 0,
"errmsg": "OK",
"ext": "",
"detail": [
{
"result": 0,
"errmsg": "OK",
"mobile": "13788888888",
"nationcode": "86",
"sid": "xxxxxxx",
"fee": 1
},
{
"result": 0,
"errmsg": "OK",
"mobile": "13788888889",
"nationcode": "86",
"sid": "xxxxxxx",
"fee": 1
}
]
}
/
$random = $this->util->getRandom();
$curTime = time();
$wholeUrl = $this->url . "?accesskey=" . $this->accesskey . "&random=" . $random;
$data = new \stdClass();
$data->tel = $this->util->phoneNumbersToArray($nationCode, $phoneNumbers);
$data->type = $type;
$data->msg = $msg;
$data->sig = $this->util->calculateSig($this->secretkey, $random, $curTime, $phoneNumbers);
$data->time = $curTime;
$data->extend = $extend;
$data->ext = $ext;
return $this->util->sendCurlPost($wholeUrl, $data);
}

/**
 * 指定模板群發
 * 【注意】海外短信無群發功能
 * @param string $nationCode 國家碼,如 86 為中國
 * @param array $phoneNumbers 不帶國家碼的手機號列表
 * @param int $templId 模板 id
 * @param array $params 模板參數列表,如模板 {1}...{2}...{3},那么需要帶三個參數
 * @param string $sign 簽名,如果填空串,系統會使用默認簽名
 * @param string $extend 擴展碼,可填空串
 * @param string $ext 服務端原樣返回的參數,可填空串
 * @return string json string { "result": xxxxx, "errmsg": "xxxxxx" ... },被省略的內容參見協議文檔
 */
function sendWithParam($nationCode, $phoneNumbers, $templId, $params, $sign = "", $extend ="", $ext = "") {

/
請求包體
{
"tel": [
{
"nationcode": "86",
"mobile": "13788888888"
},
{
"nationcode": "86",
"mobile": "13788888889"
}
],
"sign": "Kewail",
"tpl_id": 19,
"params": [
"驗證碼",
"1234",
"4"
],
"sig": "fdba654e05bc0d15796713a1a1a2318c",
"time": 1479888540,
"extend": "",
"ext": ""
}
應答包體
{
"result": 0,
"errmsg": "OK",
"ext": "",
"detail": [
{
"result": 0,
"errmsg": "OK",
"mobile": "13788888888",
"nationcode": "86",
"sid": "xxxxxxx",
"fee": 1
},
{
"result": 0,
"errmsg": "OK",
"mobile": "13788888889",
"nationcode": "86",
"sid": "xxxxxxx",
"fee": 1
}
]
}
/
$random = $this->util->getRandom();
$curTime = time();
$wholeUrl = $this->url . "?accesskey=" . $this->accesskey . "&random=" . $random;
$data = new \stdClass();
$data->tel = $this->util->phoneNumbersToArray($nationCode, $phoneNumbers);
$data->sign = $sign;
$data->tpl_id = $templId;
$data->params = $params;
$data->sig = $this->util->calculateSigForTemplAndPhoneNumbers(
$this->secretkey, $random, $curTime, $phoneNumbers);
$data->time = $curTime;
$data->extend = $extend;
$data->ext = $ext;
return $this->util->sendCurlPost($wholeUrl, $data);
}
}

更多,歡迎關注云服務-Kewail科技
官網:https://www.kewail.com/
免認證專用注冊:
https://www.kewail.com/register.html?uid=1542971565991&cmo=4

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

葫芦岛市| 青州市| 同心县| 灌云县| 开平市| 佛学| 盐边县| 十堰市| 平泉县| 万山特区| 清镇市| 清苑县| 北流市| 本溪| 桦南县| 武穴市| 英吉沙县| 新巴尔虎左旗| 澄迈县| 大宁县| 沈阳市| 通许县| 清远市| 黄平县| 泸溪县| 石首市| 延寿县| 二连浩特市| 丰县| 乳源| 乐山市| 商城县| 布尔津县| 南部县| 长葛市| 丰镇市| 夏河县| 固始县| 托克逊县| 新蔡县| 景泰县|