我正在尝试学习如何使用Twilio发送短信,我正在使用教程中的示例代码。当我运行代码时,它会将消息发送到我的手机至少两次。我错过了什么吗?
这是C#代码:
using System;
using System.Collections.Generic;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Types;
namespace Quickstart
{
class SmsSender
{
static void Main(string[] args)
{
// Find your Account Sid and Auth Token at twilio.com/user/account
const string accountSid = "xxxxxxxxxxxxxxxxxxxxxxx";
const string authToken = "xxxxxxxxxxxxxxxxxxxxxx";
// Initialize the Twilio client
TwilioClient.Init(accountSid, authToken);
// Send a new outgoing SMS by POSTing to the Messages resource
MessageResource.Create(
from: new PhoneNumber("XXXXXXXXX"), // From number, must be an SMS-enabled Twilio number
to: new PhoneNumber("XXXXXXXXX"), // To number, if using Sandbox see note above
// Message content
body: $"This is a test.");
Console.WriteLine($"Sent message to Andrew");
}
}
}