为什么我从 nexmo 发送短信回调中得到 message-count = 3?
Why do I get message-count = 3 from nexmo send SMS callback?
我使用 Node.js 发送短信是这样的:
const Nexmo = require('nexmo');
const nexmo = new Nexmo({
apiKey: process.env.NEXMO_API_KEY,
apiSecret: process.env.NEXMO_API_SECRET
});
const opts = {
'type': 'unicode'
};
function sendSMS(to, content) {
nexmo.message.sendSms('qwe, to, content, opts, (err, data) => {
if (err) return console.error(err);
console.log('Data: ', data);
})
}
在回调数据之后,我得到这样的响应:
{
"message-count":"3",
"messages":[
{
"to":"380967547714",
"message-id":"0C000000E412D0DB",
"status":"0",
"remaining-balance":"238.91280000",
"message-price":"0.07300000",
"network":"25503"
},
{
"to":"380967547714",
"message-id":"0C000000E412D0DC",
"status":"0",
"remaining-balance":"238.91280000",
"message-price":"0.07300000",
"network":"25503"
},
{
"to":"380967547714",
"message-id":"0C000000E412D0DD",
"status":"0",
"remaining-balance":"238.91280000",
"message-price":"0.07300000",
"network":"25503"
}
]
}
我有一个合理的问题:为什么我得到 "message-count": 3?
事实证明,我得到了 3 个 webhook。它应该像这样工作吗?
我可以看到您正在发送 Unicode 消息。 Unicode 内容允许的最大长度为 70 个字符,而 "normal" 短信最多允许 160 个字符。
当单个短信正文超过 70 个字符时,短信将被拆分为多个部分,然后在手机级别进行重构。
这就是为什么您收到对已发送消息的多个 webhook 调用的原因。
如果您要以 "normal" 文本 SMS 而不是 Unicode 类型发送消息,则单个 SMS 将有 160 个字符。
我使用 Node.js 发送短信是这样的:
const Nexmo = require('nexmo');
const nexmo = new Nexmo({
apiKey: process.env.NEXMO_API_KEY,
apiSecret: process.env.NEXMO_API_SECRET
});
const opts = {
'type': 'unicode'
};
function sendSMS(to, content) {
nexmo.message.sendSms('qwe, to, content, opts, (err, data) => {
if (err) return console.error(err);
console.log('Data: ', data);
})
}
在回调数据之后,我得到这样的响应:
{
"message-count":"3",
"messages":[
{
"to":"380967547714",
"message-id":"0C000000E412D0DB",
"status":"0",
"remaining-balance":"238.91280000",
"message-price":"0.07300000",
"network":"25503"
},
{
"to":"380967547714",
"message-id":"0C000000E412D0DC",
"status":"0",
"remaining-balance":"238.91280000",
"message-price":"0.07300000",
"network":"25503"
},
{
"to":"380967547714",
"message-id":"0C000000E412D0DD",
"status":"0",
"remaining-balance":"238.91280000",
"message-price":"0.07300000",
"network":"25503"
}
]
}
我有一个合理的问题:为什么我得到 "message-count": 3? 事实证明,我得到了 3 个 webhook。它应该像这样工作吗?
我可以看到您正在发送 Unicode 消息。 Unicode 内容允许的最大长度为 70 个字符,而 "normal" 短信最多允许 160 个字符。
当单个短信正文超过 70 个字符时,短信将被拆分为多个部分,然后在手机级别进行重构。
这就是为什么您收到对已发送消息的多个 webhook 调用的原因。
如果您要以 "normal" 文本 SMS 而不是 Unicode 类型发送消息,则单个 SMS 将有 160 个字符。