宅男噜噜噜66在线观看,亚洲精品一区二区三区精品,亚洲一区二区三区乱码在线欧洲,亚洲精品久久麻豆蜜桃,亚洲色无色a片一区二区

您是否正受到短信簽名報(bào)備的困擾?互億無線解決方案讓您最快15分鐘內(nèi)恢復(fù)信息傳遞,馬上 注冊(cè)體驗(yàn)。
所有文檔
銀行信息核驗(yàn)
應(yīng)用開發(fā)
短信服務(wù)
文檔中心 > 短信服務(wù) > 營(yíng)銷短信

營(yíng)銷短信

Java對(duì)接短信營(yíng)銷批量提交接口接口DEMO示例
本文為您提供了Java語言版本的短信營(yíng)銷批量提交接口接口對(duì)接DEMO示例

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.*;

public class test
{
    public static void main(String args[])
    {
        String url = "https://api.ihuyi.com/sms-yx/v1/batchSend";

        Map<String, String> headers = new HashMap<>();
        headers.put("Content-Type", "application/json; charset=utf-8");

        String jsonString = "{\"api_id\":\"mms-xxxxxxxx\",\"signature\":\"92b2919615570ceb0fa8a1b6c87c9a7a\",\"timestamp\":1756092730,\"request_id\":\"17560927306063\",\"product_id\":1001,\"phone\":[\"18800000000\",\"18800000001\"],\"sign_name\":\"xxxxxxxx\",\"title\":\"xxxxxxxxxxxx\",\"content\":\"尊敬的會(huì)員您好:${name},您的訂單號(hào)是:${order_no},拒收請(qǐng)回復(fù)R\",\"template_id\":1,\"template_var\":{\"${name}\":\"張三\",\"${order_no}\":\"202009041156181103\"},\"send_time\":\"2020-08-26 16:08:14\"}";
        
        try {
            // 確保jsonString不為空再發(fā)送請(qǐng)求
            if (jsonString != null) {
                Map<String, Object> response = sendRequest(url, headers, jsonString, "POST");

                // 打印響應(yīng)
                System.out.printf("狀態(tài)碼: %s%n", response.get("status"));
                System.out.printf("響應(yīng)內(nèi)容: %s%n", response.get("body"));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static Map<String, Object> sendRequest(String url, Map<String, String> headers, String requestBody, String method) throws Exception {
        HttpRequest.Builder requestBuilder = HttpRequest.newBuilder()
            .uri(URI.create(url))
            .method(method, requestBody.isEmpty() ? 
                HttpRequest.BodyPublishers.noBody() : 
                HttpRequest.BodyPublishers.ofString(requestBody, StandardCharsets.UTF_8));
        headers.forEach(requestBuilder::header);
        HttpClient httpClient = HttpClient.newBuilder().build();
        HttpResponse<String> response = httpClient.send(
            requestBuilder.build(),
            HttpResponse.BodyHandlers.ofString(StandardCharsets.UTF_8)
        );
        Map<String, Object> result = new HashMap<>();
        result.put("status", response.statusCode());
        result.put("body", response.body());
        return result;
    }

}

5分鐘快速自助開通免費(fèi)體驗(yàn)賬戶

在線咨詢
電話咨詢

服務(wù)熱線:

4008 808 898

服務(wù)熱線(工作時(shí)間):

4008 808 898

業(yè)務(wù)咨詢(非工作時(shí)間):

售后咨詢(非工作時(shí)間):