Skip to content

Instantly share code, notes, and snippets.

@dprothero
Created March 1, 2017 18:31
Show Gist options
  • Save dprothero/165f0544d752ade2c29841d7882efa8e to your computer and use it in GitHub Desktop.
Save dprothero/165f0544d752ade2c29841d7882efa8e to your computer and use it in GitHub Desktop.
Send SMS with Twilio 5.x helper library with manually created TwilioRestClient
using System;
using Twilio.Clients;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Types;
namespace ConsoleApplication32
{
class Program
{
static void Main(string[] args)
{
// Your Account SID from twilio.com/console
var accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
// Your Auth Token from twilio.com/console
var authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");
var client = new TwilioRestClient(accountSid, authToken);
var message = MessageResource.Create(
to: new PhoneNumber("+15558675309"),
from: new PhoneNumber("+15017250604"),
body: "Hello from C#",
client: client);
Console.WriteLine(message.Sid);
Console.Write("Press any key to continue.");
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment