Book Image

Twilio Best Practices

Book Image

Twilio Best Practices

Overview of this book

Table of Contents (15 chapters)
Twilio Best Practices
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

C#


The C# Twilio library is available on NuGet (https://www.nuget.org), which is the standard package manager for the Microsoft .NET platform. If you don't have it installed, check out http://docs.nuget.org/docs/start-here/installing-nuget for instructions.

To install the package in Visual Studio from within your project, right-click on References in your project, choose the Manage NuGet Packages option (shown in the following screenshot), and then search for Twilio. Find the Twilio package, and then click on Install.

In your code, you'll just need to import the library and then instantiate a client (client.cs):

using Twilio;
var accountSid = System.Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID")
var authToken = System.Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN")
var client = new TwilioRestClient(accountSid, authToken);

Once you've set up your client, the syntax for sending a message is comparable to PHP with pre-determined argument lists (send_sms.cs):

var message = client...