【问题标题】:Twilio: RestAPI for SMS returns status "WaitingForActivation"Twilio:用于 SMS 的 RestAPI 返回状态“WaitingForActivation”
【发布时间】:2019-08-03 01:16:58
【问题描述】:

我正在使用 Twilio Rest-Api 从我的 Controller 类发送 SMS,它返回:Id = 166,Status = WaitingForActivation,Method = "{null}",Result = "{Not yet computed}"

 public Task SendSmsAsync(string number, string message)
    {

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

        TwilioClient.Init(accountSid, authToken);

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

我从 Controller 类调用这个方法:

var result =  _smsSender.SendSmsAsync("+92331234566", "Hi its my first msg to ya. Twilio")

它正在返回状态:waitingForActivation。

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

【问题讨论】:

    标签: sms twilio twilio-api two-factor-authentication


    【解决方案1】:

    这里是 Twilio 开发者宣传员。

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

    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);
    }
    

    也请查看blog post for a good example

    【讨论】:

    • 我已经尝试了很多解决方案,也是你提到的那个。现在,我收到了这个错误:'Permission to send an SMS has not been enabled for the region indicated by the 'To' number: +92xxxxxxxxxx
    • 啊,为此您需要在 Twilio 控制台中转至 SMS geo permissions,并确保您检查了要发送到的国家/地区。
    猜你喜欢
    • 2020-08-04
    • 1970-01-01
    • 1970-01-01
    • 2021-06-13
    • 2013-06-28
    • 1970-01-01
    • 2020-03-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多