php - 将太多电话号码传递给 url 失败 - 发送短信 API

标签 php mysql sms

我有一个正在构建并在其中实现短信 API 的应用程序,但它发送到几个号码,当我从数据库中选择所有号码并发送时,它应该发送到大约 1100 个号码,但它什么也没做。

我发现它没有发送,因为数字被传递到的 url 的长度,因为我回显了数字并将它们复制到早些时候发送的文本区域。

我也把数量减少到大约一百五十,但它没有抛出错误但没有发送,我该如何更正。

请参阅下面的发送示例代码

    $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); }

这是我的代码的 post 示例,它甚至没有看到变量 send_it 等等。但是 Get 方法可以看到所有内容并且工作正常。

关于php - 将太多电话号码传递给 url 失败 - 发送短信 API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34381999/

相关文章:

android - Android 设备上短信的默认字符集/编码是什么?

php - 如何解析stdclass

php - 梦幻足球: Compare a team's average points to the league average?

mysql - Amazon RDS 备份/快照实际上是如何工作的?

java - 如何从 Java 发送短信?

MySQL 将数据从 5.1 迁移到 5.6 - 威胁

java - 无法连接到我的数据库

php - MySQL JOIN -> 从右表中获取所有数据,即使没有匹配项

php - MySQL - 有没有办法保持数据集的引用完整性?

php - SQL 计算一列中最常用的值,而另一列等于某项。