Skip to content

Instantly share code, notes, and snippets.

@musicm122
Created January 12, 2017 19:56
Show Gist options
  • Save musicm122/3bf7af22017e7ad40865d2750dde2f48 to your computer and use it in GitHub Desktop.
Save musicm122/3bf7af22017e7ad40865d2750dde2f48 to your computer and use it in GitHub Desktop.
Simple Twilio .net example: Making a call and sending an sms
public static class PhoneApi
{
public static void SendMessage(string messageText, string phoneNumber)
{
var accountSid = "YourAccountSid"; // Your Account SID from www.twilio.com/console
var authToken = "YourAuthToken"; // Your Auth Token from www.twilio.com/console
var fromNumber = "+Your From Number";
var twilio = new TwilioRestClient(accountSid, authToken);
var message = twilio.SendMessage(fromNumber, phoneNumber, messageText);
}
public static void StartPhoneCall(string messageText, string phoneNumber)
{
var accountSid = "YourAccountSid"; // Your Account SID from www.twilio.com/console
var authToken = "YourAuthToken"; // Your Auth Token from www.twilio.com/console
var fromNumber = "+Your From Number";
var twilio = new TwilioRestClient(accountSid, authToken);
var call = twilio.InitiateOutboundCall(
fromNumber, // The number of the phone initiating the call
phoneNumber, // The number of the phone receiving call
"" //"http://demo.twilio.com/welcome/voice/" // The URL Twilio will request when the call is answered
);
var message = twilio.SendMessage(fromNumber, phoneNumber, messageText);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment