HTTP SEND JAVA

By
JAVA Code Example - Sending SMS

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;

public class SMSClient {
    public static String sendSMS(String username, String password, String senderId, String recipient, String message) {
        try {
            String urlStr = String.format(
                "https://api.sendmode.com/httppost.aspx?username=%s&password=%s&senderid=%s&numto=%s&data1=%s",
                URLEncoder.encode(username, "UTF-8"),
                URLEncoder.encode(password, "UTF-8"),
                URLEncoder.encode(senderId, "UTF-8"),
                URLEncoder.encode(recipient, "UTF-8"),
                URLEncoder.encode(message, "UTF-8")
            );

            URL url = new URL(urlStr);
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod("GET");

            BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            StringBuilder response = new StringBuilder();
            String inputLine;

            while ((inputLine = in.readLine()) != null) {
                response.append(inputLine);
            }

            in.close();
            conn.disconnect();

            return response.toString();
        } catch (Exception e) {
            e.printStackTrace();
            return "Error sending SMS: " + e.getMessage();
        }
    }

    public static void main(String[] args) {
        String response = sendSMS("your_username", "your_password", "your_senderid", "recipient_number", "your_message_content");
        System.out.println(response);
    }
}