Question

High Volume SMS Support in Java sdk

  • 21 January 2021
  • 1 reply
  • 235 views

Does Ring Central Java SDK have any methods to support

1) sending High Volume SMS.

2) reading High Volume SMS from message store


1 reply

Userlevel 1

We have not released a new Java SDK version to support High Volume SMS yet. Right now, you can use the current RingCentral Java SDK version this way.

public class Message {
    public String[] to;
    public String text = "";
}
public class A2PBody {
    public String from = "";
    public String text = "";
    public Message[] messages;
}
public class Filters {
    public String view = "";
    public String dateFrom = "";
    public String dateTo = "";
}
// if you want to broadcast a single message to multiple recipients
public void broadcast_a2p_sms() throws RestException, IOException{
    A2PBody body = new A2PBody();
    body.from = "Your-HighVolume-SMS-Number";
    body.text = "Hello High Volume SMS from Java";
    String[] recipients = new String[] {"+1650xxxxxxx", "+1408xxxxxxx"};
    Message[] messages = new Message[2];
    for (int i=0; i<messages.length; i++) {
        Message m = new Message();
        m.to = new String[] {recipients[i]};
        messages[i] = m;
    }
    body.messages = messages;
    ResponseBody resp = restClient.post("/restapi/v1.0/account/~/a2p-sms/batch", body);
    System.out.println(resp.string());
}
// if you want to send custom message to each recipient
public void send_a2p_sms() throws RestException, IOException{
    A2PBody body = new A2PBody();
    body.from = "Your-HighVolume-SMS-Number";
    body.text = "";
    String[] recipients = new String[] {"+1650xxxxxxx", "+1408xxxxxxx"};
    String[] names = new String[] {"John Smith", "Matthew Frank"};
    Message[] messages = new Message[2];
    for (int i=0; i<messages.length; i++) {
        Message m = new Message();
        m.text = "Hello " + names[i];
        m.to = new String[] {numbers[i]};
        messages[i] = m;
    }
    body.messages = message
    ResponseBody resp = restClient.post("/restapi/v1.0/account/~/a2p-sms/batch", body);
    System.out.println(resp.string());
}
// read the HV SMS message store
public void get_a2p_sms() throws RestException, IOException {
    var params = new Filters();
    params.view = "Detailed";
    params.dateFrom = "2021-01-01T00:00:00.000Z";
    params.dateTo = "2021-01-21T00:00:00.000Z";

    ResponseBody resp = restClient.get("/restapi/v1.0/account/~/a2p-sms/messages", params);
    System.out.println(resp.string());
}

Check out the Dev Guide for more details about reading the HV SMS message store.

Reply