这是我的代码
$to="[\"<mobile number>\"]";
$text = "غثس هفس خن";
$arr = unpack('H*hex', iconv('UTF-8', 'UCS-2BE', $text));
$message = strtoupper($arr['hex']);
$authToken="3fUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.clickatell.com/rest/message");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"text\":\"$message\",\"to\":$to}");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"X-Version: 1",
"Content-Type: application/json",
"Accept: application/json",
"Authorization: Bearer $authToken"
));
$response = curl_exec($ch);
$err = curl_error($ch);
curl_close($ch);
当我使用此发送时,我收到一些数字作为短信
从Clickatell文档中,我得到一个解决方案,将名为'unicode'的参数添加为'1'。
然后我像这样更改了参数行
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"text\":\"$message\",\"to\":$to\",\"unicode\":1}");
现在我得到了{"error":{"code":"100","description":"Data malformed","documentation":"http://www.clickatell.com/help/apidocs/error/100.htm"}}