callr-sdk-java

CALLR API Java SDK

License

License

Categories

Categories

Java Languages
GroupId

GroupId

com.callr
ArtifactId

ArtifactId

callr-sdk-java
Last Version

Last Version

1.5.0
Release Date

Release Date

Type

Type

jar
Description

Description

callr-sdk-java
CALLR API Java SDK
Project URL

Project URL

http://github.com/THECALLR/sdk-java
Source Code Management

Source Code Management

http://github.com/THECALLR/sdk-java/tree/master

Download callr-sdk-java

How to add to project

<!-- https://jarcasting.com/artifacts/com.callr/callr-sdk-java/ -->
<dependency>
    <groupId>com.callr</groupId>
    <artifactId>callr-sdk-java</artifactId>
    <version>1.5.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.callr/callr-sdk-java/
implementation 'com.callr:callr-sdk-java:1.5.0'
// https://jarcasting.com/artifacts/com.callr/callr-sdk-java/
implementation ("com.callr:callr-sdk-java:1.5.0")
'com.callr:callr-sdk-java:jar:1.5.0'
<dependency org="com.callr" name="callr-sdk-java" rev="1.5.0">
  <artifact name="callr-sdk-java" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.callr', module='callr-sdk-java', version='1.5.0')
)
libraryDependencies += "com.callr" % "callr-sdk-java" % "1.5.0"
[com.callr/callr-sdk-java "1.5.0"]

Dependencies

compile (2)

Group / Artifact Type Version
com.google.code.gson : gson jar [2.3.1,)
commons-codec : commons-codec jar 1.10

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

sdk-java

CALLR Java SDK

Dependencies

The CALLR API uses JSON-RPC which needs to be parsed, google-gson is used for this task and needs to be included in your classes, please see https://github.com/google/gson for more information.

The apache commons codec library is also required for Base64 encoding, please see https://commons.apache.org/proper/commons-codec/ for more information.

The jars folder contains the jar of the CALLR SDK.

Basic Example (Send SMS)

See full example in samples

// Set your credentials
Api tc = new Api(new LoginPasswordAuth("login", "password"), null);

Hashtable<String, Object> param = new Hashtable<String, Object>();
param.put("flash_message", false);

// 1. "call" method: each parameter of the method as an argument
result = tc.call("sms.send", "SMS", "+33123456789", "Hello, world", param);

// "sms.send" API method return a string so it need to be converted.
System.out.println(result.getAsString());

// 2. "send" method: parameter of the method is an array
ArrayList array = new ArrayList();
array.add("SMS");
array.add("+33123456789");
array.add("Hello, world");
array.add(param);

result = tc.send("sms.send", array);

System.out.println(result.getAsString());

Authentication with Login as

Using login as

// Set your credentials
Api tc = new Api(new LoginPasswordAuth("login", "password"), null);

// Set LoginAs
tc.setLoginAs("user", "<login>"); // available types: user, account
                                  // available targets: <login> for type user, <hash> for type account

result = tc.call("sms.send", "SMS", "+33123456789", "Hello, world", null);
System.out.println(result.getAsString());
...

Reset login as

// Set your credentials
Api tc = new Api(new LoginPasswordAuth("login", "password"), null);

// Set LoginAs
tc.setLoginAs("user", "<login>"); // available types: user, account
                                  // available targets: <login> for type user, <hash> for type account

result = tc.call("sms.send", "SMS", "+33123456789", "Hello, world", null);
System.out.println(result.getAsString());
...
// Reset login as
tc.setLoginAs(null);
...

Change login as

// Set your credentials
Api tc = new Api(new LoginPasswordAuth("login", "password"), null);

// Set LoginAs
tc.setLoginAs("user", "<login>"); // available types: user, account
                                  // available targets: <login> for type user, <hash> for type account

result = tc.call("sms.send", "SMS", "+33123456789", "Hello, world", null);
System.out.println(result.getAsString());
...
// Change login as
tc.setLoginAs("account","<account hash>");
...

Authentication methods

Login/Password (Basic) authentication

import com.callr.auth.*;

// Set your credentials
Api tc = new Api(new LoginPasswordAuth("login", "password"), null);
result = tc.call("sms.send", "SMS", "+33123456789", "Hello, world", null);
...

Api-Key token authentication

import com.callr.auth.*;

// Set your credentials
Api tc = new Api(new ApiKeyAuth("987654321abcdef987654321abcdef987654321abcdef987654321abcdef987654321abcdef987654321abcdef987654321a"), null);
result = tc.call("sms.send", "SMS", "+33123456789", "Hello, world", null);
...

User Session token authentication

import com.callr.auth.*;

// Set your credentials
Api tc = new Api(new UserSessionAuth("987654321abcdef987654321abcdef987654321a"), null);
result = tc.call("sms.send", "SMS", "+33123456789", "Hello, world", null);
...
com.callr

CALLR

Versions

Version
1.5.0
1.4.0
1.2
1.1