PHP interface example, API SMS channel


Interface SMS platform provides complete status query,
Support status interface SMS API to push detailed online interface documents,
Check it at any time, update the standard HTTP interface constantly,
Multiple language examples are provided

Support for multiple return formats 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 needs to register with kewail interface SMS platform by oneself and then enter the new registration link: click enter (register is to send 20 free SMS) 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,
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 =

Interface note: the successful return of the interface does not mean the successful reception. The specific receiving status can only be inquired by the operator. Kewail platform can send and receive 10 messages with one number and one signature within one minute, only 50 messages within one hour, and 150 messages at most in one day. If users want to send a large number of messages every day, they can contact the customer service of kewail platform to set free limit, and send unlimited messages for one number in one day.

More, welcome to the cloud service -Kewail technology

Certification free special registration: start certification free registration

Recommended Today

The way of nonlinear optimization

Mathematical knowledge 1、 Nonlinear functionLinear function is another name of a function of first degree, then nonlinear function means that the function image is not a function of a straight line.Nonlinear functions include exponential function, power function, logarithmic function, polynomial function and so on. 2、 Taylor expansion1. Taylor formula:Taylor’s formula is to add a_ The […]