I have installed twilio api in my c# project and import library. Now I want to send sms from WF Application. I used this format(https://www.twilio.com/docs/api/rest/sending-messages), but TwilioRestClient 'SendMessage' method does not detect. I get compiler error. -Microsoft Visual Studio 2015 -I have installed all Twilio packages from Nutget. Twilio,Twilio.Mvc,Twilio.Twiml
0
votes
am add twilio, twilio.Mvc,twilio,Twiml referances
- Mehemmed
Can you expand on "does not detect"? Are you getting a compiler error? If you can you post that error?
- Devin Rader
Yes compailer error
- Mehemmed
Can you post the compiler error? Can you also post what version of Visual Studio you're using and what version of .NET you are targeting? Finally, can you also make sure that when you install the nuget package that you're choosing to install the highest version of its dependencies. You should see version 105.X.X of RestSharp installed.
- Devin Rader
3 Answers
2
votes
You can use the below code. Its available at this link https://www.twilio.com/docs/libraries/csharp Its working fine in VS2015 update3
using System;
using System.Threading.Tasks;
using Twilio;
using Twilio.Clients;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Types;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
SendSms().Wait();
Console.Write("Press any key to continue.");
Console.ReadKey();
}
static async Task SendSms()
{
var accountSid = "ACba92b39902bc361138fea39fee0a41b7"; // Your Account SID from twilio.com/console
var authToken = "{{ auth_token }}"; // Your Auth Token from twilio.com/console
TwilioClient.init(accountSid, authToken);
var restClient = new TwilioRestClient(accountSid, authToken);
var message = await
new MessageCreator(
new PhoneNumber("+12345678901"), // To number
accountSid,
"Hello from C#"
).CreateAsync(restClient);
Console.WriteLine(message.GetSid());
}
}
}
2
votes