我正在使用以下代码向网关短信发送消息。
curl_setopt($ch, CURLOPT_URL, 'https://urlgateway');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{ \"message\": \"Hi, ". "This is the message\",
\"phoneNumbers\": [\"phone sender\", \"phone target\"] }");
curl_setopt($ch, CURLOPT_USERPWD, 'username' . ':' . 'password');
$headers = array();
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
如您所见,消息是单行“嗨,这是一条测试消息”
我怎样才能打破前任的电话线。
"Hi,<br>
This is the message"
我尝试添加
\n
但收到有关 json 解析正文的错误..
有人可以帮忙吗? 谢谢
解决了,谢谢帮助我的人..
顺便说一句,解决方案很简单..
只需用格式化文本编写 var.. 使用键盘上的(shift+return)即可。
$data = [ 'message' => 'Hi,
This is the row1,
this is the row 2,
(shift+return) on each line,
',];