【问题标题】:Twilio send sms to a list with 100+ numbers. Twilio throwing 11200 ErrorTwilio 向包含 100 多个号码的列表发送短信。 Twilio 抛出 11200 错误
【发布时间】:2018-03-02 10:32:39
【问题描述】:

我制作了一个控制器,可以将消息发送到传入消息中指定的列表。 当我发送完所有消息后,我想返回一个 TwiML 响应。

但是,如果列表太大,Twilio 似乎会超时。 如果列表包含 10 个数字,则返回响应,如果它包含 40 个数字,则 Twilio 会在仪表板中显示 11200 错误。

总是发送传出消息,它只是失败的响应。

我做过这样的事情:

foreach (var receiver in receivers)
{
    try
    {
        await MessageResource.CreateAsync(
            from: new PhoneNumber(SomeGroupName),
            to: new PhoneNumber(receiver.Mobile),
            body: SomeOutgoingMessage);
    } 
    catch (SomeException e)
    {
        //Errorhandling
    }
}
response.Message("Message sent to all members")
return TwiML(response);

有人知道为什么会这样吗?有没有其他方法可以做到这一点?

【问题讨论】:

    标签: c# twilio twilio-api twilio-twiml


    【解决方案1】:

    这里是 Twilio 开发者宣传员。

    Twilio 将等待 15 秒以等待来自您的应用程序的响应。如果您的应用程序耗时超过 15 秒,Twilio will record an 11200 error。在您的情况下,将消息发送到 10 个号码所需的时间不到 15 秒,但对于 40 个号码则需要更长的时间。

    如果所有消息都相同,那么我建议使用 Twilio Notify 只需一个 API 请求即可发送所有消息。我在how to send bulk SMS messages with Twilio and Node.js 上写了一篇博文。我知道您使用的是 C#,但对于解释和演练,值得一读。

    用于send bulk SMS with C# 的代码应如下所示:

    using System;
    using System.Collections.Generic;
    using Twilio;
    using Twilio.Rest.Notify.V1.Service;
    
    public class Example
    {
        public static void Main(string[] args)
        {
            // Find your Account SID and Auth Token at twilio.com/console
            const string accountSid = "your_account_sid";
            const string authToken = "your_auth_token";
            const string serviceSid = "your_messaging_service_sid";
    
            TwilioClient.Init(accountSid, authToken);
    
            var notification = NotificationResource.Create(
                serviceSid,
                toBinding: new List<string> { "{\"binding_type\":\"sms\",\"address\":\"+15555555555\"}",
                "{\"binding_type\":\"sms\",\"address\":\"+123456789123\"}" },
                body: "Hello Bob");
    
            Console.WriteLine(notification.Sid);
        }
    }
    

    让我知道这是否有帮助。

    【讨论】:

    • 我认为这可以解决问题。所有的消息都是一样的:)
    • 甜,听起来是正确的解决方案。如果还有什么我可以帮忙的,请大声告诉我。
    【解决方案2】:

    https://www.twilio.com/docs/api/errors/11200

    看起来 Twilio 执行该操作所花费的时间比您的应用愿意等待它执行该操作的时间长。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-04
      • 1970-01-01
      • 2016-03-15
      • 1970-01-01
      • 2015-01-04
      • 1970-01-01
      相关资源
      最近更新 更多