Twilio:RestAPI用于SMS返回状态;“等待激活”;

Twilio:RestAPI用于SMS返回状态;“等待激活”;,sms,twilio,twilio-api,two-factor-authentication,Sms,Twilio,Twilio Api,Two Factor Authentication,我正在使用Twilio Rest Api从我的控制器类发送SMS,它返回:Id=166,Status=WaitingForActivation,Method=“{null}”,Result=“{Not Not computed}” 我正在从控制器类调用此方法: var result = _smsSender.SendSmsAsync("+92331234566", "Hi its my first msg to ya. Twilio") 它正在返回状态:等待激活 如果我使整个过程异步化,这个

我正在使用Twilio Rest Api从我的控制器类发送SMS,它返回:Id=166,Status=WaitingForActivation,Method=“{null}”,Result=“{Not Not computed}”

我正在从控制器类调用此方法:

var result =  _smsSender.SendSmsAsync("+92331234566", "Hi its my first msg to ya. Twilio")
它正在返回状态:等待激活


如果我使整个过程异步化,这个问题会得到解决吗??虽然我已经尝试过了,但不知何故我还没有找到解决方案。

这里是Twilio开发者的福音传道者

您使用的是异步方法,因此结果将是一个尚未解决的任务。我不是C#开发人员,但我相信您需要将
async
wait
关键字放在正确的位置。比如:

public async Task SendSmsAsync(string number, string message)
{

    var accountSid = Options.SMSAccountIdentification;
    var authToken = Options.SMSAccountPassword;

    TwilioClient.Init(accountSid, authToken);

    return await MessageResource.CreateAsync(
      to: new PhoneNumber(number),
      from: new PhoneNumber(Options.SMSAccountFrom),
      body: message);
}

也来看看这个。

这里是Twilio开发者福音传道者

您使用的是异步方法,因此结果将是一个尚未解决的任务。我不是C#开发人员,但我相信您需要将
async
wait
关键字放在正确的位置。比如:

public async Task SendSmsAsync(string number, string message)
{

    var accountSid = Options.SMSAccountIdentification;
    var authToken = Options.SMSAccountPassword;

    TwilioClient.Init(accountSid, authToken);

    return await MessageResource.CreateAsync(
      to: new PhoneNumber(number),
      from: new PhoneNumber(Options.SMSAccountFrom),
      body: message);
}

也可以看看这个。

我已经尝试了很多解决方案,也是您提到的那个。现在,我收到了这个错误:
“发送短信的权限尚未为“收件人”号码所指示的地区启用:+92xxxxxxxxx
啊,为此,您需要在Twilio控制台中转到,并确保您检查了发送到的国家。我已经尝试了许多解决方案,也是您提到的解决方案。现在,我收到了这个错误:
“发送短信的权限尚未为“收件人”号码所指示的地区启用:+92xxxxxxxxx
啊,因此您需要在Twilio控制台中转到,并确保您已检查了发送到的国家/地区。”。