phpmysqlsmssms-gatewaybulksms

sending bulk sms stops in middle


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

?>

Solution

  • 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);