Java

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

public class SPIRIcom_get {

    public static void main(String[] args) {

        /* Change this to your username */
        String user = "myuser";

        /* Change this to your password */
        String pass = "mypass";

        /* This is the short message to be sent */
        String msg = "test";

        /* Sender of the short message */
        String from = "+467123456789";

        /* Recipient of the short message */
        String to = "+467123456789";

        /* Construct the URL */
        String urlStr = "http://get.spiricom.spirius.com:55000/cgi-bin/sendsms?User=" + user + "&Pass=" + pass + "&From=" + from + "&To=" + to + "&Msg=" + msg;

        String result = "";
        try {
            /* Open a connection and send the GET-request */
            URL url = new URL(urlStr);
            URLConnection conn = url.openConnection();

            /* Read the response */
            BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            StringBuffer sb = new StringBuffer();
            String line;
            while ((line = rd.readLine()) != null) {
                sb.append(line);
            }
            rd.close();
            result = sb.toString();
        } catch (Exception e) {
            result = e.toString(); //e.printStackTrace();
        }
        System.out.println(result);
    }

}