twilio-java 0 travis-ci

A Java library for communicating with the Twilio REST API and generating TwiML.

3 years after

Build Status

Installing

twilio-java uses Maven. At present the jars are available from a public maven repository.

Use the following dependency in your project:

   <dependency>
      <groupId>com.twilio.sdk</groupId>
      <artifactId>twilio</artifactId>
      <version>7.X.X</version>
      <scope>compile</scope>
   </dependency>

If you want to compile it yourself, here's how:

$ git clone [email protected]:twilio/twilio-java
$ cd twilio-java
$ mvn install       # Requires maven, download from http://maven.apache.org/download.html

Quickstart

Send a SMS

String accountSid = "ACXXXXXX"; // Your Account SID from www.twilio.com/user/account
String authToken = "XXXXXXXX"; // Your Auth Token from www.twilio.com/user/account

Twilio.init(accountSid, authToken);

Message message = Message.creator(
    new PhoneNumber("+15558881234"),  // To number
    new PhoneNumber("+15559994321"),  // From number
    "Hello world!"                    // SMS body
).create();

System.out.println(message.getSid());

Make a call

String accountSid = "ACXXXXXX"; // Your Account SID from www.twilio.com/user/account
String authToken = "XXXXXXXX"; // Your Auth Token from www.twilio.com/user/account

Twilio.init(accountSid, authToken);

Call call = Call.creator(
    new PhoneNumber("+15558881234"),  // To number
    new PhoneNumber("+15559994321"),  // From number

    // Read TwiML at this URL when a call connects (hold music)
    new URI("http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient")
).create();

System.out.println(call.getSid());

Generating TwiML

To control phone calls, your application needs to output TwiML. TwiML in twilio-java now use the builder pattern!

TwiML twiml = new VoiceResponse.Builder()
    .say(new Say.Builder("Hello World!").build())
    .play(new Play.Builder("https://api.twilio.com/cowbell.mp3").loop(5).build())
    .build();

That will output XML that looks like this:

<Response>
    <Say>Hello World!</Say>
    <Play loop="5">https://api.twilio.com/cowbell.mp3</Play>
</Response>

Documentation

The documentation for the Twilio API can be found here

Getting help

If you need help installing or using the library, please contact Twilio Support at [email protected] first. Twilio's Support staff are well-versed in all of the Twilio Helper Libraries, and usually reply within 24 hours.

If you've instead found a bug in the library or would like new features added, go ahead and open issues or pull requests against this repo!

Related Repositories

cloudrail-si-java-sdk

cloudrail-si-java-sdk

Unified API Library for: Cloud Storage, Social Profiles, Payment, Email, SMS & P ...

react-native-twilio-ip-messaging

react-native-twilio-ip-messaging

React Native wrapper for the Twilio IP Messaging SDKs (Deprecated) ...

gae-chat

gae-chat

GAE group chat example app (Java) ...

bluemix-cloud-connectors

bluemix-cloud-connectors

Simplifies the way Java developers connect to services in Bluemix. ...

bluemix-cloud-connectors

bluemix-cloud-connectors

Simplifies the way Java developers connect to services in Bluemix. ...


Top Contributors

jingming skimbrel dougblack ihumanable AlexPayment carlosdp ChristerF gbin eanderle senthgit Beans0063 frankstratton kyleconroy gramanathaiah juggernaut mitchfriedman codylerum andrewmbenton kwhinnery Ragil takuji mniebla spaceman1066 adamzr panchenko obourgain caseysoftware AlekSi kelnos akshar100

Releases

-   twilio-java-sdk-vide zip tar
-   twilio-java-sdk-beta zip tar
-   twilio-java-sdk-7.0. zip tar
-   twilio-java-sdk-7.0. zip tar
-   twilio-java-sdk-7.0. zip tar
-   twilio-java-sdk-7.0. zip tar
-   twilio-java-sdk-7.0. zip tar
-   twilio-java-sdk-7.0. zip tar
-   twilio-java-sdk-7.0. zip tar
-   twilio-java-sdk-7.0. zip tar
-   twilio-java-sdk-7.0. zip tar
-   twilio-java-sdk-7.0. zip tar
-   twilio-java-sdk-7.0. zip tar
-   twilio-java-sdk-6.3. zip tar
-   twilio-java-sdk-6.2. zip tar
-   twilio-java-sdk-6.1. zip tar
-   twilio-java-sdk-6.0. zip tar
-   twilio-java-sdk-6.0. zip tar
-   twilio-java-sdk-5.12 zip tar
-   twilio-java-sdk-5.11 zip tar
-   twilio-java-sdk-5.10 zip tar
-   twilio-java-sdk-5.10 zip tar
-   twilio-java-sdk-5.9. zip tar
-   twilio-java-sdk-5.8. zip tar
-   twilio-java-sdk-5.7. zip tar
-   twilio-java-sdk-5.7. zip tar
-   twilio-java-sdk-5.6. zip tar
-   twilio-java-sdk-5.5. zip tar
-   twilio-java-sdk-5.5. zip tar
-   twilio-java-sdk-5.4. zip tar