Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/242.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用php循环发送多条短信_Php_Bulksms - Fatal编程技术网

如何使用php循环发送多条短信

如何使用php循环发送多条短信,php,bulksms,Php,Bulksms,使用循环发送多条SMS时出现问题,无法工作 代码为: while ($row = mysql_fetch_array($result)) { $dealer_name = $row['dealer_name']; $dealer_contact_no = $row['contact_no']; $date = new DateTime($row['date']); $date = $date->format('d-M-y

使用循环发送多条SMS时出现问题,无法工作

代码为:

 while ($row = mysql_fetch_array($result)) {

        $dealer_name = $row['dealer_name'];
        $dealer_contact_no = $row['contact_no'];

        $date = new DateTime($row['date']);
        $date = $date->format('d-M-y');
        $due_date = new DateTime($row['due_date']);
        $due_date = $due_date->format('d-M-y');

        //////////////////sms body 
        $msg = '';
        $msg .= 'Bill Payable-' . "%0A";
        $msg .= 'Bill No:' . $row['ref_no'] . "%0A";
        $msg .= 'Date:' . $date . "%0A";
        $msg .= 'Total Amt:' . $row['total_amount'] . "%0A";
        $msg .= 'Pending Amt:' . $row['pending_amount'] . "%0A";
        $msg .= 'Due Date:' . $due_date . "%0A";
        $msg .= 'Days:' . $row['days'] . "%0A";
        $msg .= '-' . $sender_name;

        $username = "*********";
        $password = "*********";
        $text = $msg;
        $phones = $dealer_contact_no;

        if (strlen($phones) == 10) {
       $url = 'http://bulksms.mysmsmantra.com:8080/WebSMS/SMSAPI.jsp?username=' . $username . '&password=' . $password . '&sendername=NETSMS&mobileno=' . $phones . '&message=' . $text;

        $ch = curl_init(); 
        curl_setopt($ch,CURLOPT_URL,$url);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
        $output = curl_exec($ch);
        curl_close($ch);
        }
    }
如何反复执行url以发送多条短信。。
请帮忙。。前面我使用了header()函数,但它只适用于获取的单行。

代码看起来不错。只需使用create函数检查从while中选取并调用的代码片段

功能如下:

//This function used to send SMS 
function sendSMS($username, $password, $phones, $text){

   $url = 'http://bulksms.mysmsmantra.com:8080/WebSMS/SMSAPI.jsp?username=' . $username . '&password=' . $password . '&sendername=NETSMS&mobileno=' . $phones . '&message=' . $text;

    $ch = curl_init(); 
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
    $output = curl_exec($ch);
    curl_close($ch);
}
从while中删除相同的代码并调用此函数

循环类似于:

while ($row = mysql_fetch_array($result)) {

    $dealer_name = $row['dealer_name'];
    $dealer_contact_no = $row['contact_no'];

    $date = new DateTime($row['date']);
    $date = $date->format('d-M-y');
    $due_date = new DateTime($row['due_date']);
    $due_date = $due_date->format('d-M-y');

    //////////////////sms body 
    $msg = '';//Variable initialize with blank...
    $msg .= 'Bill Payable-' . "%0A";
    $msg .= 'Bill No:' . $row['ref_no'] . "%0A";
    $msg .= 'Date:' . $date . "%0A";
    $msg .= 'Total Amt:' . $row['total_amount'] . "%0A";
    $msg .= 'Pending Amt:' . $row['pending_amount'] . "%0A";
    $msg .= 'Due Date:' . $due_date . "%0A";
    $msg .= 'Days:' . $row['days'] . "%0A";
    $msg .= '-' . $sender_name;

    $username = "abc";
    $password = "1922345418";
    $text = $msg;
    $phones = $dealer_contact_no;

    //If Phone number length equals 10 then call send SMS functionality...
    if (strlen($phones) == 10) {
        //Send SMS function calling...
        sendSMS($username, $password, $phones, $text);
    }
}

如果有任何问题/疑问,请告诉我。

代码看起来不错。只需使用create函数检查从while中选取并调用的代码片段

功能如下:

//This function used to send SMS 
function sendSMS($username, $password, $phones, $text){

   $url = 'http://bulksms.mysmsmantra.com:8080/WebSMS/SMSAPI.jsp?username=' . $username . '&password=' . $password . '&sendername=NETSMS&mobileno=' . $phones . '&message=' . $text;

    $ch = curl_init(); 
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
    $output = curl_exec($ch);
    curl_close($ch);
}
从while中删除相同的代码并调用此函数

循环类似于:

while ($row = mysql_fetch_array($result)) {

    $dealer_name = $row['dealer_name'];
    $dealer_contact_no = $row['contact_no'];

    $date = new DateTime($row['date']);
    $date = $date->format('d-M-y');
    $due_date = new DateTime($row['due_date']);
    $due_date = $due_date->format('d-M-y');

    //////////////////sms body 
    $msg = '';//Variable initialize with blank...
    $msg .= 'Bill Payable-' . "%0A";
    $msg .= 'Bill No:' . $row['ref_no'] . "%0A";
    $msg .= 'Date:' . $date . "%0A";
    $msg .= 'Total Amt:' . $row['total_amount'] . "%0A";
    $msg .= 'Pending Amt:' . $row['pending_amount'] . "%0A";
    $msg .= 'Due Date:' . $due_date . "%0A";
    $msg .= 'Days:' . $row['days'] . "%0A";
    $msg .= '-' . $sender_name;

    $username = "abc";
    $password = "1922345418";
    $text = $msg;
    $phones = $dealer_contact_no;

    //If Phone number length equals 10 then call send SMS functionality...
    if (strlen($phones) == 10) {
        //Send SMS function calling...
        sendSMS($username, $password, $phones, $text);
    }
}

如果有任何问题/疑问,请告诉我。

设置
$msg=''此行前$msg.='应付票据-'。“%0A”;您已经有一个循环可以多次运行它。您的sql查询是什么?您在问题中定义了一个问题…
但是请稍候!有什么问题吗?设置
$msg=''此行前$msg.='应付票据-'。“%0A”;您已经有一个循环可以多次运行它。您的sql查询是什么?您在问题中定义了一个问题…
但是请稍候!有什么问题?结果如何?有任何错误、通知或与之相关的东西吗?您是否可以尝试退出();过一会儿?请检查它循环了多少次。我想卷发不起作用了。。我以前没用过这个。。它需要一些帮助文件吗?不,这是PHP函数不需要帮助文件。请参阅:如果我回显$url,则我得到3行表示循环正在工作。。但没有短信发送,所以我们有最后的选择来检查卷曲是否正常工作?为此,请使用:if($output){/??-if请求和数据已完全收到打印(“::Message send for“$phones.”::”);},如果需要进一步的信息,请告诉我。结果如何?有任何错误、通知或与之相关的东西吗?您是否可以尝试退出();过一会儿?请检查它循环了多少次。我想卷发不起作用了。。我以前没用过这个。。它需要一些帮助文件吗?不,这是PHP函数不需要帮助文件。请参阅:如果我回显$url,则我得到3行表示循环正在工作。。但没有短信发送,所以我们有最后的选择来检查卷曲是否正常工作?为此,请使用:if($output){/??-if请求和数据已完全收到打印(“::Message send for“$phones.”::”);},如果需要进一步的信息,请告诉我。