发送批量短信停在中间

时间:2013-11-18 08:52:57

标签: php mysql sms sms-gateway bulksms

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

<?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

?>

2 个答案:

答案 0 :(得分:0)

可能您的页面超出了最长执行时间。将以下代码放在页面顶部并尝试:

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

答案 1 :(得分:0)

在PHP脚本的顶部添加它

<?php
set_time_limit(0);