发送批量短信在中间停止 [英] sending bulk sms stops in middle

查看:113
本文介绍了发送批量短信在中间停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计,我在以下代码中有问题.我需要向24,000个手机号码发送批量短信.但是,如果我在发送150个号码后发送它,则会向我显示内部服务器错误,并停止发送其他以下号码.请仔细阅读下面给出的代码,然后回复对我有帮助的肯定代码.

Guys i have an issue in the following code. I need to send bulk sms to 24,000 mobile numbers. But if i send it after 150 number send it shows me an Internal server error and stop send other following numbers. Kindly go through the code given below and reply the positive code that can really help me.

<?php
//Code using fopen
//Change your configurations here.
//---------------------------------
$username = "username";
$api_password = "api_password";
$sender = "sender";
$domain = "domain";
$priority = "1";// 1-Normal,2-Priority,3-Marketing
$method = "POST";

//---------------------------------
for ($i = 0; $i < $var; $i++) {
    if (isset($_REQUEST['send'])) {

        $mobile = $explode_num[$i];
        $lenthof_number = strlen($mobile);
        if ($lenthof_number >= 10) {
            $message = $_REQUEST['message'];

            $username = urlencode($username);
            $password = urlencode($api_password);
            $sender = urlencode($sender);
            $message = urlencode($message);

            $parameters = "username=$username&api_password=$api_password&sender=$sender&to=$mobile&message=$message&priority=$priority";


            if ($method == "POST") {
                $opts = array(
                    'http' => array(
                        'method' => "$method",
                        'content' => "$parameters",
                        'header' => "Accept-language: en\r\n" .
                            "Cookie: foo=bar\r\n"
                    )
                );

                $context = stream_context_create($opts);

                $fp = fopen("http://$domain/pushsms.php", "r", false, $context);
            } else {
                $fp = fopen("http://$domain/pushsms.php?$parameters", "r");
            }

            $response = stream_get_contents($fp);
            fpassthru($fp);
            fclose($fp);


            if ($response == "")
                echo "Process Failed, Please check domain, username and password.";
            else
                echo "$response";


        }//third if
    }//second if


}//first if
}//main for

?>

推荐答案

您的页面可能已超过了最长执行时间.将以下代码放在页面顶部,然后尝试:

Probably your page exeeded the max execution time. Put following code on top of page and try:

ini_set("memory_limit","128M"); 
//ini_set("memory_limit","256M"); 
//this sets it unlimited
ini_set("max_execution_time",0); 

这篇关于发送批量短信在中间停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆