2
我能够通过PHP发送短信,但我不得不提到手机号码,每次我想用相同的脚本我可以发送短信到存储在我的数据库中的条目。 这里是我的代码:我如何发送短信到我的数据库条目
<?php
//Your authentication key`enter code here`
$authKey = "API key";
//Multiple mobiles numbers separated by comma
$mobileNumber = "+919425386214";
//Sender ID,While using route4 sender id should be 6 characters long.
$senderId = "Social";
//Your message to send, Add URL encoding here.
$message = urlencode("Test message");
//Define route
$route = "04";
//Prepare you post parameters
$postData = array(
'authkey' => $authKey,
'mobiles' => $mobileNumber,
'message' => $message,
'sender' => $senderId,
'route' => $route
);
if (isset($_POST['submit']))
{
//API URL
$url="https://control.msg91.com/api/sendhttp.php";
// init the resource
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $postData
//,CURLOPT_FOLLOWLOCATION => true
));
//Ignore SSL certificate verification
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
//get response
$output = curl_exec($ch);
//Print error if any
if(curl_errno($ch))
{
echo 'error:' . curl_error($ch);
}
curl_close($ch);
echo $output;
}
?>
请帮助,这样我可以发送短信给我的客户接触的人没有。存储在我的数据库
我想你想在这个变量'$ mobileNumber'的动态数据?是否在这个变量中用逗号分隔数字? –
是的,我想要的,但这个变量的值将存储在我的数据库中的数字 –
ISHAN感谢标记,我希望你的问题得到解决。 –