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

Java


The Twilio Java library can be installed using Maven (http://maven.apache.org/download.cgi), which is Java's package manager. Installation instructions are available at the aforementioned link if you don't have it installed.

To install the package, add it to the pom.xml file in your project's root directory like this:

<dependency>
  <groupId>com.twilio.sdk</groupId>
  <artifactId>twilio-java-sdk</artifactId>
  <version>3.4.6</version>
  <scope>compile</scope>
</dependency>

Next, run mvn install to get Maven to install our new package.

In your code, you'll need to import lots of libraries:

import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.factory.MessageFactory;
import com.twilio.sdk.resource.instance.Message;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import java.util.ArrayList;
import java.util.List;

Next, instantiate the...