如何使用带有 React Native 的 Twilio 发送短信 (SMS)?

How do I send a text message (SMS) with Twilio with React Native?

如何使用带有原生 React 的 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',

                   }),
                });

还有其他方法吗?

使用 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();
   })