无法发送短信与笨

问题描述:

从数据库中读取这是我的代码是用来发送短信的手机号码的手机。我可以将短信发送到多个号码,但是当我选择一个号码时,SMS不会发送。所以我放了一个if else条件来检查是否只有一个选择的数字,那么它不应该有逗号,否则它应该用逗号分隔。但现在SMS不发送到任何数字。出了什么问题。请帮帮我。无法发送短信与笨

 $college = $this->input->post('college'); 
     $count = count($college); 
     if($count == 1){ 
$mobiles = implode("" , $_POST['college']); 
} else { 
$mobiles = implode("," , $_POST['college']); 
} 
$data = array(
      'sms_date' => date('Y-m-d H:i:s'), 
      'sender' => 'Some Addresss', 
      'receiver' => $mobiles, 
      'sms_message' => $this->input->post('message') 
    );  
function curl($url) 
    { 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); 
$data = curl_exec($ch); 
curl_close($ch); 
return $data; 
} 
    //$mobile = $mobiles; 
    $username = "*****"; //your username 
    $password = "*****"; //your password 
    $sender = "****"; //Your senderid 
    $username = urlencode($username); 
    $password = urlencode($password); 
    $sender = urlencode($sender); 
    $messagecontent = $this->input->post('message'); //Type Of Your Message 
    $message = urlencode($messagecontent); 
    $url="http://****.com/sendsms?uname=".$username."&pwd=".$password."&senderid=".$sender."&to=".$mobiles."&msg=".$message."&route=T"; 
    $response = curl($url); 
+0

调用卷曲()函数。只是呼应网址回声$ URL之前确保大学不是一个空数组 – JYoThI

+0

;出口;并看到一切正确或不正确 – JYoThI

您已创建但未使用$college变量。更改此:

if($count == 1){ 
    $mobiles = implode("" , $college); 
} else { 
    $mobiles = implode("," , $college); 
} 

这样:

if($count == 1){ 
    $mobiles = implode("" , $_POST['college']); 
} else { 
    $mobiles = implode("," , $_POST['college']); 
} 

而且,如果这是真的你的密码,你应该改变它。 :)

+0

谢谢...它的工作... – julie