简体   繁体   中英

Sending SMS through Twilio and C#

We are building a ASP.NET MVC app, which requires SMS integration. I have downloaded the latest pre-release (through nuget) and used the source code as mentioned in API section. However, it seems to have an issue

var message = twilio.SendMessage(...); 
Console.WriteLine(message.Sid);... 

Where the Sid is not available in the message object. Instead I am using Status .

The actual problem is when I try to send as per the guidelines and API tokens available in the SMS testing page, I got the message.Status as "Faulted" and no SMS was sent. Even I tried with the test page @ https://www.twilio.com/user/account/developer-tools/api-explorer/message-create , that too didn't send a message indeed.

Is there anything I am missing?

Twilio evangelist here.

What .NET version is your application? The pre-release nuget package includes two different assemblies, one for .NET 4 and greater, one for .NET 3.5.

If your project is using .NET 4 or greater all of the library methods are new async, so your call to send message would look like:

var result = await twilio.SendMessage(...);
Console.WriteLine(result.Sid);

Hope that helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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