Как отправить смс в правильном формате с помощью php? - PullRequest
1 голос
/ 11 ноября 2019

В этом коде я использую смс шлюз для отправки сообщения клиенту. Теперь смс отправлено успешно, но формат выглядит следующим образом:

This is a remainder about the title by the 2019-11-11 hello

выглядит просто. Я хочу показать, что сообщение должно выглядеть так:

This is a remainder about the titleby 2019-11-11 hello Строка должна быть разбита после about, title, date и message

Так как я могу это сделать? Пожалуйста, помогите мне.

Спасибо

$message = "This is a reminder about the ".$this->input->post("title")." by the ".date("Y-m-d", strtotime($this->input->post("date")))." ".strip_tags(html_entity_decode($this->input->post("notice")))."";
$requestParams = array(
    'user' => '**********',
    'pass' => '**********',
    'sender' => '*******',
    'phone' => trim(json_encode($student_phone, JSON_NUMERIC_CHECK),'[]'),
    'text' => $message,
    'priority' => 'ndnd',
    'stype' => 'normal'
);
$apiUrl = "http://bhashsms.com/api/sendmsg.php?";
foreach($requestParams as $key => $val){
    $apiUrl .= $key.'='.urlencode($val).'&';
}

$apiUrl = rtrim($apiUrl, "&");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
$return = json_encode($result);

1 Ответ

2 голосов
/ 11 ноября 2019

Попробуйте использовать символ "новая строка" \n. Вставьте его в строку так:

$message = "This is a reminder about \n the ".$this->input->post("title")."\n by the ".date("Y-m-d", strtotime($this->input->post("date")))."\n".strip_tags(html_entity_decode($this->input->post("notice")))."";
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...