我有一个正在构建并实现sms API的应用程序,但它发送到几个号码,当我从数据库中选择所有并发送时,它应该发送到大约1100个号码,但它什么也不做。
我发现它没有发送,因为数字被传递到的url的长度,因为我呼应了数字,并将它们复制到了之前发送的文本区域。
我还将数字减少到了150左右,但它没有抛出错误,但没有发送,我该如何更正。
请参阅下面的发送示例代码
$phone_group_total = $phone_numbers.", ".$send_it.", ".$selected_staffs;
function httpRequest($fields, $sendpage){
$curl = curl_init($sendpage);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $fields);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl);
curl_close($curl);
$sendpage ="http://smsexperience.com/components/com_spc/smsapi.php?";
$sendsms ="username=user&password=pass";
$sendsms .="&sender=$sender_id";
$sendsms .="&recipient=".$phone_group_total;
$sendsms .="&message=$message";
httpRequest($sendsms, $sendpage);
我使用了get方法提交表单,我尝试使用post,但我的消息没有发送。我该如何修复它并发送到大号码集。谢谢
if(isset($_POST['send_sms']))
{
$sender_id = mysql_real_escape_string($_POST['sender_id']);
$phone_numbers = mysql_real_escape_string($_POST['phone_numbers']);
$message = ($_POST['message']);
$client_phone = ($_POST['client_phone']);
$employee_phone = ($_POST['employee_phone']);
$tailor_phone = ($_POST['tailor_phone']);
if($client_phone!="")
{
$sql = "SELECT mobile_phone FROM personal_details";
$res = mysql_query($sql) or die(mysql_error());
$recipients = array();
while($row = mysql_fetch_array($res)) {
$recipients[] = $row['mobile_phone'];
}
$send_it = implode(', ', $recipients);
}
if($employee_phone!="")
{
$sql1 = "SELECT mobile_phone FROM employee_db";
$res1 = mysql_query($sql1) or die(mysql_error());
$recipients1 = array();
while($row1 = mysql_fetch_array($res1)) {
$recipients1[] = $row1['mobile_phone'];
}
$send_it1 = implode(', ', $recipients1);
}
if($tailor_phone!="")
{
$sql2 = "SELECT mobile_phone FROM employee_db WHERE department='Tailors'";
$res2 = mysql_query($sql2) or die(mysql_error());
$recipients2 = array();
while($row2 = mysql_fetch_array($res2)) {
$recipients2[] = $row2['mobile_phone'];
}
$send_it2 = implode(', ', $recipients2);
}
if($tailor_phone !="" && $employee_phone!="")
{$selected_staffs = $send_it1;}else if($tailor_phone=='tailors' && $employee_phone=="")
{$selected_staffs = $send_it2;}else if($tailor_phone=="" && $employee_phone=='employees')
{$selected_staffs = $send_it1;}
if($_POST['phone_numbers']=="")
{
$phone_group_total = $send_it.", ".$selected_staffs;
}else{
$phone_group_total = $phone_numbers.", ".$send_it.", ".$selected_staffs;}
function httpRequest ($fields, $sendpage){
$curl = curl_init($sendpage);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $fields);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl);
curl_close($curl);
}
$sendpage ="http://smsexperience.com/components/com_spc/smsapi.php?";
$sendsms ="username=user&password=pass";
$sendsms .="&sender=$sender_id";
$sendsms .="&recipient=".$phone_group_total; $sendsms .="&message=$message";
httpRequest($sendsms, $sendpage); }
这是我的代码的后示例,它甚至看不到变量send_it等等。但是Get方法可以看到所有内容,并且运行良好。
我现在能够解决向url传递过多参数的问题,方法是使用post方法,并将if(isset($_post['send_sms'])改为if($_SERVER['REQUEST_method']="post"),然后开始正确提交表单值并发送短信,mysql_real.sescape_string将行转换为字符,数字不会提交给sms API,因此解决方案是删除命令mysql_real_sescape_string,而sms对长数字集的作用就像魔术一样。