You have installed Java (minimal required version is Java 7).
It is recommended that you use a dependency management system to get started with using Infobip Java API client in your project. You can choose between Maven and Gradle. Depending on your choice find the appropriate configuration below.
For using the API client in your maven project add the following snippet to the <dependencies>
section
of your pom.xml
file:
<dependency>
<groupId>com.infobip</groupId>
<artifactId>infobip-api-java-client</artifactId>
<version>2.1.0</version>
</dependency>
For adding the API client to your gradle project add the following line to the dependencies
section
of your build.gradle
file:
compile "com.infobip:infobip-api-java-client:2.1.0"
If you choose not to use any tool for dependency management you can still use the Infobip API client. A
.jar
with the API client and all of its dependencies can be found at maven central repository.
From the list there click on jar-with-dependencies.jar
link to download the .jar
file that you
can manually integrate into your project.
First, setup your username and password in infobip.examples.Example
. Then, you can run provided examples in
infobip.examples
package
First, initialize the messaging client using your username and password:
SendSingleTextualSms client = new SendSingleTextualSms(new BasicAuthConfiguration(USERNAME, PASSWORD));
Prepare the message:
SMSTextualRequest requestBody = new SMSTextualRequest();
requestBody.setFrom(FROM);
requestBody.setTo(Arrays.asList("xxxxxxxx", "yyyyyyyy"));
requestBody.setText("This is an example message");
Send the message:
SMSResponse response = client.execute(requestBody);
Later you can query for the delivery status of the message:
GetSentSmsDeliveryReports client = new GetSentSmsDeliveryReports(new BasicAuthConfiguration(USERNAME, PASSWORD));
SMSReportResponse response = client.execute(BULK_ID, MESSAGE_ID, LIMIT);
Similar to standard messaging example, but when preparing your message, use SMSAdvancedTextualRequest
:
SendMultipleTextualSmsAdvanced client = new SendMultipleTextualSmsAdvanced(new BasicAuthConfiguration(USERNAME, PASSWORD));
Destination destination = new Destination();
destination.setTo("xxxxxxxx");
Message message = new Message();
message.setFrom(FROM);
message.setDestinations(Collections.singletonList(destination));
message.setText(MESSAGE_TEXT);
message.setNotifyUrl("NOTIFY_URL");
SMSAdvancedTextualRequest requestBody = new SMSAdvancedTextualRequest();
requestBody.setMessages(Collections.singletonList(message));
SMSResponse response = client.execute(requestBody);
When the delivery notification is pushed to your server as a HTTP POST request, you can process the body of the message with the following code:
SMSReportResponse smsReportResponse = gson.fromJson(requestBody, SMSReportResponse.class);
This library is licensed under the Apache License, Version 2.0