Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Twilio Best Practices

You're reading from   Twilio Best Practices Learn how to build powerful real-time voice and SMS applications with Twilio

Arrow left icon
Product type Paperback
Published in Dec 2014
Publisher
ISBN-13 9781782175896
Length 178 pages
Edition 1st Edition
Tools
Arrow right icon
Toc

Table of Contents (10) Chapters Close

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...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime