那年夏天 2019-11-17
kewail
接口短信平台提供完备状态查询,
支持状态接口短信api推送详尽的在线接口文档,
随时查阅,不断更新标准HTTP接口,
提供多种语言示例
(PHPJAVAC#NODEPYTHON等)支持多种返回格式 JSON/XML// Works well with php5.3
and php5.6.namespace KewailSms;class SmsSenderUtil {function
getRandom() {return rand(100000, 999999);}function
calculateSig($secretkey, $random, $curTime, $phoneNumbers)
{$phoneNumbersString = $phoneNumbers[0];for ($i = 1; $i <
count($phoneNumbers); $i++) {$phoneNumbersString .= ("," .
$phoneNumbers[$i]);}return hash("sha256",
"secretkey=".$secretkey."&random=".$random."&time=".$curTime."&mobile=".$phoneNumbersString);}//secretkey需要自行到kewail接口短信平台注册后新成注册链接:点击进入(注册即送20条免费短信)function
calculateSigForTemplAndPhoneNumbers($secretkey, $random, $curTime,
$phoneNumbers) {$phoneNumbersString = $phoneNumbers[0];for ($i = 1; $i
< count($phoneNumbers); $i++) {$phoneNumbersString .= ("," .
$phoneNumbers[$i]);}return hash("sha256",
"secretkey=".$secretkey."&random=".$random."&time=".$curTime."&mobile=".$phoneNumbersString);}function phoneNumbersToArray($nationCode, $phoneNumbers) {$i = 0;$tel =
array();do {$telElement = new \stdClass();$telElement->nationcode =
$nationCode;$telElement->mobile = $phoneNumbers[$i];array_push($tel,
$telElement);} while (++$i < count($phoneNumbers));return
$tel;}function calculateSigForTempl($secretkey, $random, $curTime,
$phoneNumber) {$phoneNumbers = array($phoneNumber);return
$this->calculateSigForTemplAndPhoneNumbers($secretkey, $random,
$curTime, $phoneNumbers);}function sendCurlPost($url, $dataObj) {$curl
= curl_init();curl_setopt($curl, CURLOPT_URL, $url);curl_setopt($curl, CURLOPT_HEADER, 0);curl_setopt($curl, CURLOPT_RETURNTRANSFER,
1);curl_setopt($curl, CURLOPT_POST, 1);curl_setopt($curl,
CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($curl, CURLOPT_POSTFIELDS,
json_encode($dataObj));curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,
0);curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);curl_setopt($curl,
CURLOPT_HTTPHEADER, array('Content-Type: application/json',
'Content-Length: ' . strlen(json_encode($dataObj)))); $ret =
curl_exec($curl);if (false == $ret) {// curl_exec failed$result = "{
"result":" . -2 . ","errmsg":"" . curl_error($curl) . ""}";}
else {$rsp = curl_getinfo($curl, CURLINFO_HTTP_CODE);if (200 != $rsp)
{$result = "{ \"result\":" . -1 . ",\"errmsg\":\"". $rsp . " " .
curl_error($curl) ."\"}";} else {$result =
$ret;}}curl_close($curl);return
$result;}
接口备注:接口返回成功不代表接收成功,具体接收状态只能由运营商查询;kewail平台同1个号码同1个签名的内容1分钟内能发送接收10条,1小时内只能接收50条,一天最多接收150条,如需每天大量发送用户可以联系kewail平台客服设置免限,一天可针对一个号码无限量发送短信。
更多,欢迎关注云服务-Kewail科技
免认证专用注册:开始免认证注册