Skip to content

twizoapi/lib-api-java

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
out
 
 
 
 
 
 
 
 
 
 
 
 

Twizo

Twizo Java API

Connect to the Twizo API using Java. This API includes functions to send verifications (2FA), SMS and Number Lookup.

Requirements

  • Java >= 8
  • Maven

Get application secret and api host

To use the Twizo API client, the following things are required:

Installation

At this moment there are 2 options to use the Twizo Java library (IntelliJ)

Maven

  1. Add Maven Framework to your project by right clicking the project folder -> Add Framework Support -> Maven
  2. Add the lib-api-java module module to your project
  3. Add the module as a dependency to your pom.xml file
<dependency>
    <groupId>com.twizo</groupId>
    <artifactId>lib-api-java</artifactId>
    <version>0.1.0</version>
</dependency>
  1. Make sure to mark the src folder as source directory to be able to use the Twizo classes
  2. Reimport (or enable auto-import) Maven

Jar file

  1. Put the lib-api-java.jar file in your lib folder
  2. Add the library to the project in the Project Structure -> Libraries menu

In the near future this library will be available from the Maven Central Repository

Getting started

Initializing the Twizo Api using your api secret and api host

import com.twizo.TwizoFactory;
import com.twizo.Twizo;

class MyClass {

    private static void main(String[] args) {
        Twizo twizo = new TwizoFactory("your-api-key", Node.ASIA);
    }
    
}

Send a sms

SmsController smsController = twizo.getSmsController();

// parameters = recipient phone number - message - sender phone number
smsController.sendSimple("60123456789", "Hello World", "60987654321");

Create a new NumberLookup

NumberLookupController numberLookupController = twizo.getNumberLookupController();

// parameter = phone number to look up
numberLookupController.createSimpleNumberLookup("60123456789");

Create a new Verification

VerificationController verificationController = twizo.getVerificationController();

// parameter = phone number to receive token
verificationController.createSimpleVerification("60123456789");

Verify a token

VerificationController verificationController = twizo.getVerificationController();

// parameter = token to verify
verificationController.verifyToken("012345");

Examples

In the examples directory you can find a collection of cli examples of how to use the api. When first running an example you will be asked for a host name and apiKey; this will be written to a properties file.

Testing

To run the Unit Tests provided with this code, you have to enter your API key in the TestSetup class in the tests directory.

License

The MIT License. Copyright (c) 2017 Twizo

Support

Contact: www.twizo.comsupport@twizo.com

About

Java library for the Twizo api.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages