> For the complete documentation index, see [llms.txt](https://doc.antgst.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.antgst.com/demo/java-demo.md).

# Java Demo

### Download Complete Demo

{% embed url="<https://antgst-sys.oss-ap-southeast-1.aliyuncs.com/Demo/ANT-JAVA-Demo.zip>" %}
Download Demo
{% endembed %}

#### Maven Dependencies <a href="#maven-dependencies" id="maven-dependencies"></a>

<pre data-title="pom.xml" data-line-numbers><code><strong>&#x3C;?xml version="1.0" encoding="UTF-8"?>
</strong>&#x3C;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">
    &#x3C;modelVersion>4.0.0&#x3C;/modelVersion>

    &#x3C;groupId>org.example&#x3C;/groupId>
    &#x3C;artifactId>ANT-Demo&#x3C;/artifactId>
    &#x3C;version>1.0-SNAPSHOT&#x3C;/version>

    &#x3C;dependencies>
        &#x3C;dependency>
            &#x3C;groupId>cn.hutool&#x3C;/groupId>
            &#x3C;artifactId>hutool-all&#x3C;/artifactId>
            &#x3C;version>5.8.5&#x3C;/version>
        &#x3C;/dependency>
    &#x3C;/dependencies>

&#x3C;/project>
</code></pre>

#### marketing <a href="#marketing" id="marketing"></a>

```
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 <a href="#notification" id="notification"></a>

```
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);

    }

}


```
