How to send sms to multiple contacts and get the result code for each of them. It is not working. I get opened only the last number in the 'numbers' string and not to all of them.
What am I doing wrong?
In my controller,
foreach ($sendarraystudent as $studentid) {
//$i++;
$student = Student::model()->findByPk($studentid);
$name = $student->student_firstname . " " . $student->student_middlename . " " . $student->student_lastname;
$smobile = $student->student_mobile;
//$mobilelist = $mobilelist . ',' . $smobile;
$msg1 = $msg;
$msg1 = str_replace("#course#", $course->course_name, $msg);
$msg1 = str_replace("#batch#", $batch->batch_name, $msg1);
$msg1 = str_replace("#name#", $name, $msg1);
$this->sendbulk($smobile, $msg1);
}
protected function sendbulk($mobilenum, $message) {
$no = $mobilenum;
$msg = $message;
$link = "http://url/api/v3/index.php?method=sms&api_key=A6xxxxxxxxxxx&to=" . $no . "&sender=xxxxxx&message=" . $msg . "&unicode=xxx";
header('Location: ' . $link) and exit;
}
I think it is because you use redirect header('Location: ' . $link) and exit;
. Processing only one sms. Try this:
foreach ($sendarraystudent as $studentid) {
//...
$link = "http://url/api/v3/index.php?method=sms&api_key=A6xxxxxxxxxxx&to=" . $student->student_mobile . "&sender=xxxxxx&message=" . $msg1 . "&unicode=xxx"
$content = file_get_contents($link);
echo $content;
}