infobip.examples.SendSmsExample Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of infobip-api-java-client Show documentation
Show all versions of infobip-api-java-client Show documentation
API client in Java for Infobip's API (http://dev.infobip.com/).
package infobip.examples;
import infobip.api.client.SendSingleTextualSms;
import infobip.api.config.BasicAuthConfiguration;
import infobip.api.model.sms.mt.send.SMSResponse;
import infobip.api.model.sms.mt.send.SMSResponseDetails;
import infobip.api.model.sms.mt.send.textual.SMSTextualRequest;
import java.util.Arrays;
public class SendSmsExample extends Example {
public static void main(String[] args) {
SendSingleTextualSms client = new SendSingleTextualSms(new BasicAuthConfiguration(USERNAME, PASSWORD));
SMSTextualRequest requestBody = new SMSTextualRequest();
requestBody.setFrom(FROM);
requestBody.setTo(Arrays.asList(TO, TO_2));
requestBody.setText(MESSAGE_TEXT);
SMSResponse response = client.execute(requestBody);
for (SMSResponseDetails sentMessageInfo : response.getMessages()) {
System.out.println("Message ID: " + sentMessageInfo.getMessageId());
System.out.println("Receiver: " + sentMessageInfo.getTo());
System.out.println("Message status: " + sentMessageInfo.getStatus().getName());
System.out.println("------------------------------------------------");
}
}
}