Created
January 12, 2017 19:56
-
-
Save musicm122/3bf7af22017e7ad40865d2750dde2f48 to your computer and use it in GitHub Desktop.
Simple Twilio .net example: Making a call and sending an sms
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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