<?php
function textTicket($mobile_number, $ticket){
$str = substr($mobile_number, 1);
$mobileNumber = (string)"63" . $str;
$userTicket = (string)$ticket;
$messageId = (string)mt_rand(1000000000, 9999999999);
$messageToUser = "Thank you for using CSC-QMSMS: Your Filing Ticket Number: ".$userTicket." will be called soon. You're in the 5th person in the line. ";
$arr_post_body = array(
"message_type" => "SEND",
"mobile_number" => $mobileNumber,
"shortcode" => "292905464",
"message_id" => $messageId,
"message" => urlencode($messageToUser),
"client_id" => "757867ea2047771fea041a40684334dccee81cd07c81f006e556298e9eb42b00",
"secret_key" => "4f16aea773532b9cb9bf8330b8b34c8248b9b482255213c2504575faab8e4bcb"
);
$query_string = "";
foreach($arr_post_body as $key => $frow)
{
$query_string .= '&'.$key.'='.$frow;
}
$URL = "https://post.chikka.com/smsapi/request";
$curl_handler = curl_init();
curl_setopt($curl_handler, CURLOPT_URL, $URL);
curl_setopt($curl_handler, CURLOPT_POST, count($arr_post_body));
curl_setopt($curl_handler, CURLOPT_POSTFIELDS, $query_string);
curl_setopt($curl_handler, CURLOPT_RETURNTRANSFER, TRUE);
$response = curl_exec($curl_handler);
curl_close($curl_handler);
$txtResponse = json_encode($response);
$pos = strpos($txtResponse, "ACCEPTED");
return $pos;
}
?>
$query_string = "";
foreach($arr_post_body as $key => $frow)
{
$query_string .= '&'.$key.'='.$frow;
}
$URL = "https://post.chikka.com/smsapi/request";
$curl_handler = curl_init();
curl_setopt($curl_handler, CURLOPT_URL, $URL);
curl_setopt($curl_handler, CURLOPT_POST, count($arr_post_body));
curl_setopt($curl_handler, CURLOPT_POSTFIELDS, $query_string);
curl_setopt($curl_handler, CURLOPT_RETURNTRANSFER, TRUE);
$response = curl_exec($curl_handler);
curl_close($curl_handler);
$txtResponse = json_encode($response);
$pos = strpos($txtResponse, "ACCEPTED");
return $pos;
1条答案
按热度按时间7eumitmz1#
首先,您需要找到另一个SMS API提供商,并找出通过该API发送消息所需的内容。您很可能需要注册并接收某种凭据或令牌。
阅读新API的文档。找出需要发送哪些参数。
然后:
1.将
$URL
的值替换为新API的URL1.删除
$arr_post_body
中的所有键,并添加新API所需的键。