Coder Social home page Coder Social logo

govindaraju777 / twilio-java Goto Github PK

View Code? Open in Web Editor NEW

This project forked from twilio/twilio-java

0.0 1.0 0.0 29.76 MB

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

Home Page: https://www.twilio.com/docs/libraries/java

License: MIT License

Makefile 0.01% Java 99.99% Dockerfile 0.01%

twilio-java's Introduction

twilio-java

Build Status Maven Central

Documentation

The documentation for the Twilio API can be found here.

The Java library documentation can be found here.

Recent Update

As of release 7.14.0, Beta and Developer Preview products are now exposed via the main twilio-java artifact. Releases of the alpha branch have been discontinued.

If you were using the alpha release line, you should be able to switch back to the normal release line without issue.

If you were using the normal release line, you should now see several new product lines that were historically hidden from you due to their Beta or Developer Preview status. Such products are explicitly documented as Beta/Developer Preview both in the Twilio docs and console, as well as through in-line code documentation here in the library.

Installing

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

Use the following dependency in your project to grab via Maven:

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

or Gradle:

implementation "com.twilio.sdk:twilio:7.X.X"

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 https://maven.apache.org/download.html

Versions

twilio-java uses a modified version of Semantic Versioning for all changes. See this document for details.

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>

Docker Image

The Dockerfile present in this repository and its respective twilio/twilio-java Docker image are currently used by Twilio for testing purposes only.

Getting help

If you need help installing or using the library, please check the Twilio Support Help Center first, and file a support ticket if you don't find an answer to your question.

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!

twilio-java's People

Contributors

alexpayment avatar andrewmbenton avatar beans0063 avatar carlosdp avatar childish-sambino avatar christerf avatar cjcodes avatar codejudas avatar codylerum avatar dougblack avatar eanderle avatar frankstratton avatar gbin avatar gramanathaiah avatar ihumanable avatar ilanbiala avatar jingming avatar jmctwilio avatar juggernaut avatar jwitz10 avatar krisgutta avatar kwhinnery avatar kyleconroy avatar panchenko avatar ragil avatar senthgit avatar skimbrel avatar sullis avatar twilio-ci avatar wanjunsli avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.