简体   繁体   English

Twilio不发送短信

[英]Twilio not sending SMS

I've tried this code 我已经试过这段代码

string AccountSid = "[mySID]"; 
string AuthToken = "[myAuthCode]"; 

var twilio = new TwilioRestClient(AccountSid, AuthToken);

var me = twilio.SendMessage("+15016536555", "+923355216606", "A blank txt");
Console.WriteLine(me.Sid); 

I put my original SID and AuthToken in my code. 我在代码中放入了原始的SID和AuthToken。 The me.Sid is giving null . me.Sidnull Moreover, the To number is also registered. 而且, To号码也被登记。

I noted that the To and From in me variable is empty.Their is only send and recieve date and time. 我注意到To to From in me变量为空,它们仅发送和接收日期和时间。

在此处输入图片说明

I tried your code and it worked fine when To and From numbers were valid. 我尝试了您的代码,当“到”和“从”数字有效时,它可以正常工作。 I could receive the text. 我可以收到短信。 However, when I changed the From number it failed and reproduced the same problem. 但是,当我更改“发件人”编号时,它失败并重现了相同的问题。 It didn't throw an exception, just failed silently. 它没有引发异常,只是默默地失败了。

Interesting thing is there is a RestException property in the message object which displayed "The From phone number +xxxxxxxxxx is not a valid, SMS-capable inbound phone number or short code for your account." 有趣的是,消息对象中有一个RestException属性,该属性显示“发件人的电话号码+ xxxxxxxxxx不是有效的,支持SMS的入站电话号码或您帐户的短代码。” This way it was easy to identify the problem. 这样,很容易发现问题。

I installed Twilio wrapper from NuGet 我从NuGet安装了Twilio包装器

Install-Package Twilio

and the version I've just tried is 4.0.3 我刚刚尝试的版本是4.0.3

If your version is out of date, update it to the latest version so you can check the error using RestException property. 如果您的版本已过时,请将其更新为最新版本,以便可以使用RestException属性检查错误。

UPDATE: The message object and RestException in my application looks like this: 更新:我的应用程序中的消息对象和RestException看起来像这样: 在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM