这是我的代码,用于发送短信。我可以发送短信到多个号码,但是当我选择一个号码短信不发送。所以我放了一个if else条件来检查是否只选择了一个数字,然后它不应该有逗号,否则它应该用逗号分隔。但现在短信没有发送任何号码。什么可能出错。请帮帮我。
$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 :(得分:1)
您已创建但未使用$college
变量。改变这个:
if($count == 1){
$mobiles = implode("" , $college);
} else {
$mobiles = implode("," , $college);
}
到此:
if($count == 1){
$mobiles = implode("" , $_POST['college']);
} else {
$mobiles = implode("," , $_POST['college']);
}
另外,如果这确实是您的密码,您应该更改它。 :)