import java.io.BufferedReader;  
import java.io.InputStreamReader;  
import java.io.OutputStream;  
import java.net.HttpURLConnection;  
import java.net.URL;  
  
public class SMSPostExample {  
  
    // 固定参数值  
    private static final String USERID = "企业ID";  
    private static final String ACCOUNT = "账号";  
    private static final String PASSWORD = "密码";  
    private static final String URL_STRING = "http://116.62.155.121:8888/sms.aspx";  
  
    public static void main(String[] args) {  
        // 动态提取的mobile和content值（这里仅作为示例，实际应从适当的位置获取这些值）  
        String mobile = "13800138000,15900159000"; // 应从实际业务逻辑中提取  
        String content = "【云消息】您的验证码：8899"; // 应从实际业务逻辑中提取  
  
        String response = sendSMSPostRequest(mobile, content);  
        System.out.println("Response: " + response);  
    }  
  
    public static String sendSMSPostRequest(String mobile, String content) {  
        StringBuilder response = new StringBuilder();  
        try {  
            URL url = new URL(URL_STRING);  
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();  
            conn.setRequestMethod("POST");  
            conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");  
            conn.setDoOutput(true);  
  
            // 构建POST请求的参数  
            String params = String.format("action=send&rt=json&userid=%s&account=%s&password=%s&mobile=%s&content=%s&extno=",  
                    USERID, ACCOUNT, PASSWORD, mobile, content);  
  
            // 发送POST请求  
            try (OutputStream os = conn.getOutputStream()) {  
                byte[] input = params.getBytes("utf-8");  
                os.write(input, 0, input.length);  
            }  
  
            // 获取并打印响应  
            try (BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8"))) {  
                String line;  
                while ((line = br.readLine()) != null) {  
                    response.append(line);  
                }  
            }  
  
            // 检查响应状态  
            if (response.toString().contains("\"returnstatus\":\"Success\"")) {  
                System.out.println("提交成功");  
            } else {  
                System.out.println("提交失败: " + response.toString());  
            }  
  
        } catch (Exception e) {  
            e.printStackTrace();  
        }  
        return response.toString();  
    }  
}