nd
1ST 4 Connect (PVT) Limited | 2 Floor | 89-A Danepur Road | GOR 1 | Lahore | Pakistan
1ST 4 Connect (PVT) Limited | 33-C Zamzama 6 | D.H.A Phase V | Karachi | Pakistan
Lahore: +(92) 042 111-008-339 | Karachi: +(92) 021 111-008-339 | f: +92(0) 42 3742 1219
e: info@1st4connect.com| www.1st4connect.com
Business SMS API
nd
1ST 4 Connect (PVT) Limited | 2 Floor | 89-A Danepur Road | GOR 1 | Lahore | Pakistan
1ST 4 Connect (PVT) Limited | 33-C Zamzama 6 | D.H.A Phase V | Karachi | Pakistan
Lahore: +(92) 042 111-008-339 | Karachi: +(92) 021 111-008-339 | f: +92(0) 42 3742 1219
e: info@1st4connect.com| www.1st4connect.com
Table of Contents
1. Submitting Request for Business SMS API .............................................................................. 3
Example:.................................................................................................................................. 3
2. CODE EXAMPLES .................................................................................................................. 4
PHP ......................................................................................................................................... 4
PHP Using Proxy ...................................................................................................................... 5
ASP .......................................................................................................................................... 5
JAVA ........................................................................................................................................ 6
C# ............................................................................................................................................ 7
C# Using Proxy ......................................................................................................................... 8
VB6 ......................................................................................................................................... 9
VB6 Using Proxy..................................................................................................................... 10
3. Submitting Request for Business SMS API Delivery Status .................................................... 11
Example:................................................................................................................................ 11
4. Submitting Request for Business SMS API Balance Inquiry ................................................... 12
Example:................................................................................................................................ 12
Appendix-A................................................................................................................................ 13
Appendix-B ................................................................................................................................ 13
nd
1ST 4 Connect (PVT) Limited | 2 Floor | 89-A Danepur Road | GOR 1 | Lahore | Pakistan
1ST 4 Connect (PVT) Limited | 33-C Zamzama 6 | D.H.A Phase V | Karachi | Pakistan
Lahore: +(92) 042 111-008-339 | Karachi: +(92) 021 111-008-339 | f: +92(0) 42 3742 1219
e: info@1st4connect.com| www.1st4connect.com
1. Submitting Request for Business SMS API
To send a quick message, the destination address should be in the format 923xxxxxxxxx.
The basic parameters required are:
Parameters Value Description
id 92300xxxxxxx A valid Account ID for the customer.
pass xxxxxxxxxxxx A valid Account Password for the customer.
mask Outreach The mask to be used to send the message.
to 92300xxxxxxx Comma separated list of destination mobile numbers.
msg Hello The content of the message to be sent.
lang English Language is English and Urdu. Not Case sensitive.
type (optional) Xml Type is XML and json. Not Case sensitive. Default is
xml. If set, the result will be returned according to the
type specified.
Example:
Each message returns a unique identifier in the form of Transaction ID.
URL:
http://outreach.pk/api/sendsms.php/sendsms/url?id=92300xxxxxxx&pass= xxxxxxxxxxxx
&mask= Outreach&to=92300xxxxxxx&lang=English&msg=Hello&type=xml
Success Response:
<?xml version="1.0" encoding="UTF-8" ?>
<corpsms>
<code>300</code>
<type>Success</type>
nd
1ST 4 Connect (PVT) Limited | 2 Floor | 89-A Danepur Road | GOR 1 | Lahore | Pakistan
1ST 4 Connect (PVT) Limited | 33-C Zamzama 6 | D.H.A Phase V | Karachi | Pakistan
Lahore: +(92) 042 111-008-339 | Karachi: +(92) 021 111-008-339 | f: +92(0) 42 3742 1219
e: info@1st4connect.com| www.1st4connect.com
<response>Message Sent to Telecom.</response>
<transactionID>1</transactionID>
</corpsms>
Error Response:
<?xml version="1.0" encoding="UTF-8" ?>
<corpsms>
<code>200</code>
<type>Error</type>
<response>Invalid API id/password for the customer.</response>
<transactionID>1</transactionID>
</corpsms>
2. CODE EXAMPLES
PHP
<?php
// Configuration variables
$type = "xml";
$id = "92300xxxxxxx";
$pass = "xxxxxxxxxxxx";
$lang = "English";
$mask = "Outreach";
// Data for text message
$to = "92300xxxxxxx";
$message = "Test with an ampersand (&) and a 5 note";
$message = urlencode($message);
// Prepare data for POST request
$data = "id=".$id."&pass=".$pass."&msg=".$message."&to=".$to."&lang=".$lang."&mask=".$mask."&type=".$type;
// Send the POST request with cURL
$ch = curl_init('http://www.outreach.pk/api/sendsms.php/sendsms/url');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch); //This is the result from Outreach
curl_close($ch);
?>
nd
1ST 4 Connect (PVT) Limited | 2 Floor | 89-A Danepur Road | GOR 1 | Lahore | Pakistan
1ST 4 Connect (PVT) Limited | 33-C Zamzama 6 | D.H.A Phase V | Karachi | Pakistan
Lahore: +(92) 042 111-008-339 | Karachi: +(92) 021 111-008-339 | f: +92(0) 42 3742 1219
e: info@1st4connect.com| www.1st4connect.com
PHP Using Proxy
<?php
$type = "xml";
$id = "xxxx";
$pass = "xxxxxx";
$lang = "English";
$mask = "Outreach";
// Data for text message
$to = "923001234567";
$message = "Test with an ampersand (&) and a 5 note";
$message = urlencode($message); // Prepare data for POST request
$data = "id=".$id."&pass=".$pass."&msg=".$message."&to=".$to."&lang=".$lang."&mask=".$mask."&type=".$type;
// Send the POST request with cURL
$loginpassw = 'Proxy_Username:Proxy_Password'; //your proxy login and password here
$proxy_ip = 'Proxy_Server'; //proxy IP here
$proxy_port = 8080; //proxy port from your proxy list
$ch = curl_init('http://www.outreach.pk/api/sendsms.php/sendsms/url');
curl_setopt($ch, CURLOPT_HEADER, 0); // no headers in the output
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // output to variable
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_PROXYPORT, $proxy_port);
curl_setopt($ch, CURLOPT_PROXYTYPE, 'HTTP');
curl_setopt($ch, CURLOPT_PROXY, $proxy_ip);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $loginpassw);
$data = curl_exec($ch);
curl_close($ch);
echo $data;
?>
ASP
<%
responseType = "xml"
id = "92300xxxxxxx"
pass = "xxxxxxxxxxxx"
lang = "English"
nd
1ST 4 Connect (PVT) Limited | 2 Floor | 89-A Danepur Road | GOR 1 | Lahore | Pakistan
1ST 4 Connect (PVT) Limited | 33-C Zamzama 6 | D.H.A Phase V | Karachi | Pakistan
Lahore: +(92) 042 111-008-339 | Karachi: +(92) 021 111-008-339 | f: +92(0) 42 3742 1219
e: info@1st4connect.com| www.1st4connect.com
mask = "Outreach"
toNum = "92300xxxxxxx"
message = "Hello this is a test with a 5 note and an ampersand (&) symbol"
message = Server.urlencode(message) 'encode special characters (e.g. ?, & etc)
address = "http://www.outreach.pk/api/sendsms.php/sendsms/url"
url = address & "?id=" & id & "&pass=" & pass & "&msg=" & message & "&to=" & toNum & "&mask=" & mask &
"&lang=" & lang & "&type=" & responseType
set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.open "POST", url, false
xmlhttp.send ""
msg = xmlhttp.responseText
response.write(msg)
set xmlhttp = nothing
%>
JAVA
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
public class SMSSender {
public static String sendSms(String sToPhoneNo,String sMessage) {
try {
nd
1ST 4 Connect (PVT) Limited | 2 Floor | 89-A Danepur Road | GOR 1 | Lahore | Pakistan
1ST 4 Connect (PVT) Limited | 33-C Zamzama 6 | D.H.A Phase V | Karachi | Pakistan
Lahore: +(92) 042 111-008-339 | Karachi: +(92) 021 111-008-339 | f: +92(0) 42 3742 1219
e: info@1st4connect.com| www.1st4connect.com
// Construct data
String data = "id=" + URLEncoder.encode("92300xxxxxxx", "UTF-8");
data += "&pass=" + URLEncoder.encode("xxxxxxxxxxxx", "UTF-8");
data += "&msg=" + URLEncoder.encode(sMessage, "UTF-8");
data += "&lang=" + URLEncoder.encode("English", "UTF-8");
data += "&to=" + URLEncoder.encode(sToPhoneNo, "UTF-8");
data += "&mask=" + URLEncoder.encode("Outreach", "UTF-8");
data += "&type=" + URLEncoder.encode("xml", "UTF-8");
// Send data
URL url = new URL("http://www.outreach.pk/api/sendsms.php/sendsms/url");
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(data);
wr.flush();
// Get the response
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
String sResult="";
while ((line = rd.readLine()) != null) {
// Process line...
sResult=sResult+line+" ";
}
wr.close();
rd.close();
return sResult;
} catch (Exception e) {
System.out.println("Error SMS "+e);
return "Error "+e;
}
}
public static void main(String[] args) {
String result = sendSms("92300xxxxxxx","Hello this is a test with a 5 note and an ampersand (&)
symbol");
System.out.println(result);
}
}
C#
protected void Page_Load(object sender, EventArgs e)
{
lbl1.Text = readHtmlPage("http://www.outreach.pk/api/sendsms.php/sendsms/url");
}
private String readHtmlPage(string url)
{
String result = "";
String message = HttpUtility.UrlEncode("Hello this is a test with a 5 note and an ampersand (&) symbol");
String strPost = "id=92300xxxxxxx&pass=xxxxxxxx&msg=" + message +
"&to=92300xxxxxxx" + "&mask=Outreach&type=xml&lang=English";
StreamWriter myWriter = null;
HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
objRequest.Method = "POST";
nd
1ST 4 Connect (PVT) Limited | 2 Floor | 89-A Danepur Road | GOR 1 | Lahore | Pakistan
1ST 4 Connect (PVT) Limited | 33-C Zamzama 6 | D.H.A Phase V | Karachi | Pakistan
Lahore: +(92) 042 111-008-339 | Karachi: +(92) 021 111-008-339 | f: +92(0) 42 3742 1219
e: info@1st4connect.com| www.1st4connect.com
objRequest.ContentLength = Encoding.UTF8.GetByteCount(strPost);
objRequest.ContentType = "application/x-www-form-urlencoded";
try
{
myWriter = new StreamWriter(objRequest.GetRequestStream());
myWriter.Write(strPost);
}
catch (Exception e)
{
return e.Message;
}
finally
{
myWriter.Close();
}
HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
{
result = sr.ReadToEnd();
// Close and clean up the StreamReader
sr.Close();
}
return result;
}
C# Using Proxy
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
using System.Web;
namespace S4CFirewall
{
class Program
{
static void Main(string[] args)
{
string url = "http://www.outreach.pk/api/sendsms.php/sendsms/url";
String result = "";
String message = HttpUtility.UrlEncode("Hello this is a test with a 5 note and an ampersand (&) symbol");
String strPost = "id=YOUR_ID&pass=YOUR_PASSWORD&msg=" + message + "&to=92300xxxxxxx" +
"&mask=Outreach&type=xml&lang=English";
StreamWriter myWriter = null;
nd
1ST 4 Connect (PVT) Limited | 2 Floor | 89-A Danepur Road | GOR 1 | Lahore | Pakistan
1ST 4 Connect (PVT) Limited | 33-C Zamzama 6 | D.H.A Phase V | Karachi | Pakistan
Lahore: +(92) 042 111-008-339 | Karachi: +(92) 021 111-008-339 | f: +92(0) 42 3742 1219
e: info@1st4connect.com| www.1st4connect.com
HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
try
{
WebProxy myProxy = new WebProxy();
myProxy.Address = new Uri("YOUR_PROXY"); //Example : http://LHR-18P-PROX:8080
myProxy.Credentials = new NetworkCredential("YOUR_PROXY_USERNAME", "YOUR_PROXY_PASSWORD");
objRequest.Proxy = myProxy;
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.ReadLine();
}
objRequest.Method = "POST";
objRequest.ContentLength = Encoding.UTF8.GetByteCount(strPost);
objRequest.ContentType = "application/x-www-form-urlencoded";
try
{
myWriter = new StreamWriter(objRequest.GetRequestStream());
myWriter.Write(strPost);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
finally { myWriter.Close();
}
HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
using (System.IO.StreamReader sr = new System.IO.StreamReader(objResponse.GetResponseStream()))
{
result = sr.ReadToEnd(); // Close and clean up the StreamReader
sr.Close();
}
Console.WriteLine(result);
}
}
}
VB6
Dim message As String
Dim result As String
Dim myURL As String, postData As String
Dim winHttpReq As Object
message = "Hello this is a test message."
Set winHttpReq = CreateObject("WinHttp.WinHttpRequest.5.1")
nd
1ST 4 Connect (PVT) Limited | 2 Floor | 89-A Danepur Road | GOR 1 | Lahore | Pakistan
1ST 4 Connect (PVT) Limited | 33-C Zamzama 6 | D.H.A Phase V | Karachi | Pakistan
Lahore: +(92) 042 111-008-339 | Karachi: +(92) 021 111-008-339 | f: +92(0) 42 3742 1219
e: info@1st4connect.com| www.1st4connect.com
myURL = "http://www.outreach.pk/api/sendsms.php/sendsms/url"
postData = "id=92300xxxxxxx&pass=xxxxxxxxxxxx&msg=" + message +
"&to=92300xxxxxxx&mask=Outreach&type=xml&lang=English"
winHttpReq.Open "POST", myURL, False
winHttpReq.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
winHttpReq.Send (postData)
SendSMS_Text = winHttpReq.responseText
VB6 Using Proxy
Dim message As String
Dim result As String
Dim myURL As String, postData As String
Dim winHttpReq As Object
message = "Hello this is a test message."
Set winHttpReq = CreateObject("WinHttp.WinHttpRequest.5.1")
myURL = "http://www.outreach.pk/api/sendsms.php/sendsms/url"
postData = "id=xxxxxxx&pass=xxxxxx&msg=" + message +
"&to=92300xxxxxxx&mask=Outreach&type=xml&lang=English"
winHttpReq.SetProxy 2, "Proxy_Server"
winHttpReq.Open "POST", myURL, False
winHttpReq.SetCredentials "Proxy_Username", "Proxy_Password", 1
winHttpReq.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
winHttpReq.Send (postData)
SendSMS_Text = winHttpReq.ResponseText
nd
1ST 4 Connect (PVT) Limited | 2 Floor | 89-A Danepur Road | GOR 1 | Lahore | Pakistan
1ST 4 Connect (PVT) Limited | 33-C Zamzama 6 | D.H.A Phase V | Karachi | Pakistan
Lahore: +(92) 042 111-008-339 | Karachi: +(92) 021 111-008-339 | f: +92(0) 42 3742 1219
e: info@1st4connect.com| www.1st4connect.com
3. Submitting Request for Business SMS API Delivery Status
The basic parameters required are:
Parameters Value Description
id 92300xxxxxxx A valid Account ID for the customer.
pass xxxxxxxxxxxx A valid Account Password for the customer.
transaction 1 Comma separated list of transaction IDs.
Example:
URL:
http://outreach.pk/api/sendsms.php/delivery/status?id=923084443779&pass=xxxxxxxx&transaction
=1
Success Response:
<?xml version="1.0" encoding="UTF-8" ?>
<corpsms>
<transaction id="1">
<status num="92300xxxxxxx" date="07-11-2012 13:25:02">Successful</status>
</transaction>
</corpsms>
Error Response:
<?xml version="1.0" encoding="UTF-8" ?>
<corpsms>
<code>200</code>
<type>Error</type>
<response>Invalid API ID/Password</response>
</corpsms>
nd
1ST 4 Connect (PVT) Limited | 2 Floor | 89-A Danepur Road | GOR 1 | Lahore | Pakistan
1ST 4 Connect (PVT) Limited | 33-C Zamzama 6 | D.H.A Phase V | Karachi | Pakistan
Lahore: +(92) 042 111-008-339 | Karachi: +(92) 021 111-008-339 | f: +92(0) 42 3742 1219
e: info@1st4connect.com| www.1st4connect.com
4. Submitting Request for Business SMS API Balance Inquiry
The basic parameters required are:
Parameters Value Description
id 92300xxxxxxx A valid Account ID for the customer.
pass xxxxxxxxxxxx A valid Account Password for the customer.
Example:
URL:
http://outreach.pk/api/sendsms.php/balance/status?id=xxxxxxxx&pass=xxxxxxxx
Success Response:
<?xml version="1.0" encoding="UTF-8" ?>
<corpsms>
<code>100</code>
<type>Success</type>
<response>5913</response>
</corpsms>
Error Response:
<?xml version="1.0" encoding="UTF-8" ?>
<corpsms>
<code>200</code>
nd
1ST 4 Connect (PVT) Limited | 2 Floor | 89-A Danepur Road | GOR 1 | Lahore | Pakistan
1ST 4 Connect (PVT) Limited | 33-C Zamzama 6 | D.H.A Phase V | Karachi | Pakistan
Lahore: +(92) 042 111-008-339 | Karachi: +(92) 021 111-008-339 | f: +92(0) 42 3742 1219
e: info@1st4connect.com| www.1st4connect.com
<type>Error</type>
<response>Invalid API ID/Password</response>
</corpsms>
Appendix-A
Error Codes
Code Description
200 Invalid API id/password for the customer.
203 Customer account has expired.
204 Invalid SMS masking for the customer.
206 Invalid Destination Number, Please Check Format i-e 92345xxxxxxx
208 One of the required parameters is missing.
209 Account has been blocked/suspended.
210 Invalid language specified for the message.
211 Insufficient Credit in account for this SMS.
Appendix-B
Status
Code Description
100 Successful
101 UnSuccessful
300 Message Sent to Telecom.