短信不会发送到多个手机号码

时间:2017-07-11 21:26:01

标签: php codeigniter-2

在我的codeigniter项目中,sms已经集成。短信工作正常。我必须上传一个文本文件,其中包含手机号码,需要向该手机号码发送短信。我从上传的文件中获取了手机号码,但邮件没有发送。这是我的控制器代码:

public function sendBulkSms() {
    $config['upload_path'] = 'bulk_sms/';
    $config['allowed_types'] = 'txt';
    $this->load->library('upload', $config);
    if ($this->upload->do_upload('text_file')) {
        $upload_data = $this->upload->data();
    //------------------send sms---------------
        $file_content = file_get_contents(base_url()."bulk_sms/".$upload_data['file_name']);
        $mobileNO = explode(',', $file_content);
      //$mobileNO = array("8801670750680", "8801942762160");
        $smsFormat = "Hi, this is a test message";

        function httpGet($url) {
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

            $output = curl_exec($ch);
            curl_close($ch);
            return $output;
        }

        $user = "SomeUser";
        $pass = "SomePass";
        $sid = "8804445650490";
        $url = "my_sms_api_url";
        $SMSText = urlencode($smsFormat);

        foreach($mobileNO as $mobile_no){
            echo httpGet("my_sms_api_url?user=$user&password=$pass&sender=$sid&SMSText=$SMSText&GSM=$mobile_no&type=longSMS&datacoding=1");
        }
     // -----------end send sms----------            
    }
}

如果我上传包含以下手机号码的文字文件,请在浏览器中输入:

014151515,012181818,013484848

显示
 -13014151515 -13012181818 -13013484848

这里-13添加了数字

如果我使用

  

$ mobileNO = array(“016151515”,“017181818”);

insted of

  

$ mobileNO = explode(',',$ file_content);

然后它的工作原理 我无法理解添加额外数字(-13)的位置。请帮我看看。

0 个答案:

没有答案