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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;

// Simple send SMS programm
public class SendSMS {

    public static String sendSMS(String msisdn, String username, String password, String output) {
        String url;
        StringBuilder inBuffer = new StringBuilder();
        try {
            url = "http://smsc.txtnation.com:5002/checkHLR?" + "msisdn=" + msisdn + "&username=" + username + "&password=" + password + "&output=" + output;
        } catch (UnsupportedEncodingException e) {
            return null;
        }
        try {
            URL tmUrl = new URL(url);
            URLConnection tmConnection = tmUrl.openConnection();
            tmConnection.setDoInput(true);
            BufferedReader in = new BufferedReader(new InputStreamReader(tmConnection.getInputStream()));
            String inputLine;
            while ((inputLine = in.readLine()) != null)
                inBuffer.append(inputLine);
            in.close();
        } catch (IOException e) {
            return null;
        }
        return inBuffer.toString();
    }
    public static void main(String[] args) {
        // Example of use
        String response = sendSMS("msisdn", "username", "password", "xml|json");
        System.out.println(response);
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php

// Simple SMS send function
function sendSMS($msisdn, $username, $password, $output) {
    $URL = 'http://smsc.txtnation.com:5002/checkHLR?';
    $URL .= http_build_query([
        'msisdn'    => $msisdn,
        'username'  => $username,
        'password'  => $password,
        'output'    => $output
    ]);
    $fp = fopen($URL, 'r');
    return fread($fp, 1024);
}
// Example of use
$response = sendSMS('msisdn', 'username', 'password', 'xml|json');
echo $response;
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
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Web;

namespace SendSMS {
    class Program {
        public static string SendSMS(string msisdn, string username, string password, string output) {
            StringBuilder sb  = new StringBuilder();
            byte[]        buf = new byte[1024];
            string url = "http://smsc.txtnation.com:5002/checkHLR?" + "msisdn=" + msisdn + "&username=" + username + "&password=" + password + "&output=" + output;
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            Stream resStream = response.GetResponseStream();
            string tempString = null;
            int count = 0;
            do {
                count = resStream.Read(buf, 0, buf.Length);
                if (count != 0) {
                    tempString = Encoding.ASCII.GetString(buf, 0, count);
                    sb.Append(tempString);
                }
            }
            while (count > 0);
            return sb.ToString();
        }
        static void Main(string[] args) {
            string respXML = SendSMS("msisdn", "username", "password", "xml|json");
            Console.WriteLine(respXML);
       }
    }
}
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
#include <iostream>
#include <string>
#using <System.Dll>
#using <System.Web.Dll>

using namespace std;
using namespace System;
using namespace System::Web;
using namespace System::Net;
using namespace System::IO;
using namespace System::Runtime::InteropServices;

ref class SMSSender
{

public:
        SMSSender()
        {}
        String^ SendSMS(String^ msisdn, String^ username, String^ password, String^ output)
        {
                String^ URL = "http://smsc.txtnation.com:5002/checkHLR?" + "msisdn=" + msisdn + "&username=" + username + "&password=" + password + "&output=" + output;
                WebRequest^ Handle = WebRequest::Create(URL);
                WebResponse^ HTTPResponse = Handle->GetResponse();
                StreamReader^ Stream = gcnew StreamReader(HTTPResponse->GetResponseStream());
                String^ Response = Stream->ReadToEnd()->Trim();
                HTTPResponse->Close();
                return Response;
        }
};

int main() {
        SMSSender^ test = gcnew SMSSender();
        String^ resp = test->SendSMS("msisdn", "username", "password", "xml|json");
        Console::WriteLine(resp);
        return 0;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Imports System.Web

Module Module1
    Public Function SendSMS(ByVal msisdn As String, ByVal username As String, ByVal password As String, ByVal output As String)
        Dim webClient As New System.Net.WebClient
        Dim url As String = "http://smsc.txtnation.com:5002/checkHLR?" & "msisdn=" & msisdn & "&username=" & username & "&password=" & password & "&output=" & output
        Dim result As String = webClient.DownloadString(url)
        SendSMS = result
    End Function

    Sub Main()
        Dim result As String = SendSMS("msisdn", "username", "password", "xml|json")
        Console.WriteLine(result)
        Console.ReadKey()
    End Sub

End Module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<%@ language="JScript" %>
<%
    msisdn    = "msisdn";
    username  = "username";
    password  = "password";
    output    = "xml|json";
    url = "http://smsc.txtnation.com:5002/checkHLR?" + "msisdn=" + msisdn + "&username=" + username + "&password=" + password + "&output=" + output;
    var objSrvHTTP;
    objSrvHTTP = Server.CreateObject("Msxml2.ServerXMLHTTP");
    objSrvHTTP.open(url, false);
    objSrvHTTP.send();
    Response.ContentType = "text/xml";
    xmlResp = objSrvHTTP.responseXML.xml;
    Response.Write(xmlResp);
%>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
require 'net/http'
require 'uri'

def send_sms(msisdn, username, password, output)
	requested_url = 'http://smsc.txtnation.com:5002/checkHLR?' + "msisdn=" + msisdn + "&username=" + username + "&password=" + password + "&output=" + output
	url = URI.parse(requested_url)
	full_path = (url.query.blank?) ? url.path : "#{url.path}?#{url.query}"
	the_request = Net::HTTP::Get.new(full_path)
	the_response = Net::HTTP.start(url.host, url.port) { |http|
		http.request(the_request)
	}
	raise "Response was not 200, response was #{the_response.code}" if the_response.code != "200"
	return the_response.bodyend
resp = send_sms("msisdn", "username", "password", "xml|json")

puts(resp)
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
var http = require('http');

function getTestPersonaLoginCredentials(callback) {

	return http.get({
		host: 'http://smsc.txtnation.com',
		port: 5002,
		path: '/checkHLR',
		qs:{
			msisdn    : "msisdn"
			username  : "username"
			password  : "password"
			output    : "xml|json"
		}
	}, function(response) {
		// Continuously update stream with data
		var body = '';
		response.on('data', function(d) {
			body += d;
		});
		response.on('end', function() {
			callback(body);
		});
	});

}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import urllib.parse
import urllib.request

url = 'http://smsc.txtnation.com:5002/checkHLR'
values = {
	"msisdn"    : "msisdn"
	"username"  : "username"
	"password"  : "password"
	"output"    : "xml|json"
}
data = urllib.parse.urlencode(values).encode("utf-8")
req = urllib.request.Request(url, data)
response = urllib.request.urlopen(req)
the_page = response.read()
1
curl http://smsc.txtnation.com:5002/checkHLR?msisdn=msisdn&username=username&password=password&output=xml|json