ANT
  • Introduction
    • Authentication
    • Number
    • Errors
    • Rate Limits
  • ANT API
    • Balance
      • Retrieve balance
    • Sms
      • Marketing SMS
        • Send Marketing SMS
        • Send Bulk Marketing SMS
        • Scheduled Marketing SMS
        • Marketing SMS CallBack
      • 🔥OTP SMS
        • Send OTP SMS
        • OTP SMS CallBack
        • ⭐OTP Backfill Interface
      • Notification SMS
        • Send Notification SMS
        • Send Bulk Notification SMS
        • Scheduled Notification SMS
        • Notification SMS CallBack
    • Voip
      • IVR
        • IVR File Upload
        • IVR Task
        • IVR Callback
      • Call
        • Call the phone
        • Call record callback
    • Phone Number Validation
      • HLR Sever
      • VOICE HLR
      • Check Number Status
  • Webhooks
    • Test Webhooks
  • Demo
    • Java Demo
Powered by GitBook
On this page
  • Download Complete Demo
  • Notification
  1. Demo

Java Demo

PreviousDemo

Last updated 1 month ago

Download Complete Demo

Maven Dependencies

pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>ANT-Demo</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-all</artifactId>
            <version>5.8.5</version>
        </dependency>
    </dependencies>

</project>

marketing

package com.antgst.demo;

import cn.hutool.http.HttpRequest;
import cn.hutool.json.*;
import com.antgst.util.Constants;

public class SendMarketingSMS {

    public static void main(String[] args) {

        JSONObject json = new JSONObject();
        json.set("authSecret", Constants.ACCESSKEY_ID + Constants.ACCESSKEY_SECRET);
        // senderid If not, leave it blank
        // json.set("from", "senderid");

        JSONArray numbersAry = new JSONArray();
        numbersAry.put("00***"); // phone number

        json.set("numbers", numbersAry);
        json.set("sms", "Test Marketing SMS");

        String response = HttpRequest.post(Constants.URL_MARKETING)
                .header("Content-Type", "application/json")
                .body(json.toString())
                .execute().body();

        System.out.println("URL:" + Constants.URL_MARKETING
                + " Request JSON:" + json.toString()
                + " Response JSON:" + response);

    }

}

Notification

package com.antgst.demo;

import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.antgst.util.Constants;

public class SendNotificationSMS {

    public static void main(String[] args) {

        JSONObject json = new JSONObject();
        json.set("authSecret", Constants.ACCESSKEY_ID + Constants.ACCESSKEY_SECRET);
        // senderid If not, leave it blank
        // json.set("from", "senderid");

        JSONArray numbersAry = new JSONArray();
        numbersAry.put("00***");  // phone number

        json.set("numbers", numbersAry);
        json.set("sms", "Test Notification SMS");

        String response = HttpRequest.post(Constants.URL_NOTIFICATION)
                .header("Content-Type", "application/json")
                .body(json.toString())
                .execute().body();

        System.out.println("URL:" + Constants.URL_NOTIFICATION
                + " Request JSON:" + json.toString()
                + " Response JSON:" + response);

    }

}

OTP

package com.antgst.demo;

import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.antgst.util.Constants;

public class SendOTPSMS {

    public static void main(String[] args) {

        JSONObject json = new JSONObject();
        json.set("authSecret", Constants.ACCESSKEY_ID + Constants.ACCESSKEY_SECRET);
        // senderid If not, leave it blank
        // json.set("from", "senderid");

        json.set("number", "00***"); // phone number
        json.set("sms", "Test OTP SMS 123456");

        String response = HttpRequest.post(Constants.URL_OTP)
                .header("Content-Type", "application/json")
                .body(json.toString())
                .execute().body();

        System.out.println("URL:" + Constants.URL_OTP
                + " Request JSON:" + json.toString()
                + " Response JSON:" + response);

    }

}

https://antgst-sys.oss-ap-southeast-1.aliyuncs.com/Demo/ANT-JAVA-Demo.zip
Download Demo