如何使用 Twilio 发送带有原生反应的短信?
我使用此代码但不起作用:
fetch('https://api.twilio.com/2010-04-01/Accounts/ACxxxxxxxxxxx/Messages',
{
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
user:'ACxxxxxxxxxxxxxxxxxxxxxxx',
password:'f8xxxxxxxxxxxxxxxxxxxxxx',
to: '+3933850xxxx',
body: 'test',
from: '+3933850xxxx',
}),
});
还有其他方法吗?
答案 0 :(得分:0)
使用 twilio API
发送消息的示例代码const twilioClient = context.getTwilioClient();
twilioClient.messages
.create({ from: context.PHONE_NUMBER, to: phoneNumber, body: message })
.then(x => {
// If the SMS was successfully sent, remove the item from the list
return twilioClient.sync
.services(event.ServiceSid)
.syncLists(event.ListUniqueName)
.syncListItems(orderNumber)
.remove();
})