为什么 Twilio 不发送短信? [英] Why is Twilio not sending sms?

查看:47
本文介绍了为什么 Twilio 不发送短信?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试通过 Twilio Api 发送短信.但是 Twilio 不会向我发送任何短信.怎么了?

I tried send a sms via the Twilio Api. But Twilio does not send to me any sms messages. What is wrong?

参考 https://www.twilio.com/docs/api/rest/发送短信

我的代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Twilio;
namespace SMS

{
class Program
{
    static void Main(string[] args)
    {
        string AccountSid = "myAccountSid";
        string AuthToken = "{{ myAuthToken }}";
        var twilio = new TwilioRestClient(AccountSid, AuthToken);


        var sms = twilio.SendSmsMessage("myTwilioNumber", "myGsmNumber", "Test SMS", "");
        // var sms = twilio.SendSmsMessage("+14053350954", "+905xxyyyzzvv", "Test SMS", "");


        Console.WriteLine(sms.Sid);
    }
       }
         }

推荐答案

Twilio 布道者在这里.

Twilio evangelist here.

开始诊断此问题的几种方法.

Couple of ways to start diagnosing this.

首先,我建议您登录您的帐户并查看消息日志.如果您的应用实际上已成功连接到 Twilio 并告诉它发送短信,它将显示在此处.

First I'd suggest logging into your account and checking the message logs. If your app is actually successfully connecting to Twilio and telling it to send the text message, it will show up here.

如果日志中没有消息,则可能是在您尝试使用 REST API 测试 Twilio 发送消息时发生错误.要检查您是否可以查看 sms 变量上的 RestException 属性:

If there are no messages in the log its likely that there is an error happening when you try to use the REST API to test Twilio to send the message. To check that you can look at the RestException property on your sms variable:

if (sms.RestException!=null)
{
    Debug.Writeline(sms.RestException.Message);
}

如果 RestException 参数为空,则可能发生传输错误.您看到 DNS 解析失败,或 HTTP 请求超时.

If the RestException parameter is null, then there is likely a transport error happening. Either your seeing a DNS resolve failure, or an HTTP request timeout.

希望有所帮助.

这篇关于为什么 Twilio 不发送短信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆