Sei sulla pagina 1di 12

HELP ON

HOW TO POST DATA IN


DIFFERENT LANGUAGES

Page 1
Contents

API single message to single recipient ……………………………………………………3

API single message to multiple recipient……………………..……………………...……4

To get the LIVE delivery report……………………………………………………...……5

Check Balance……………………………………………………………….…6

Sample Codes

1.ASP.NET (C#) CODE…………………………………………………………………….7

2.ASP CLASSIC CODE……………………………………………………………………8

3.JAVA CODE………………………………………………………………………………9

4.PHP CODE…………………………………………………………………………….…11

5.MS SQL CODE……….……………………………………………………….…………12

Page 2
API single message to single recipient

Variable Value Details

User Name loginId This is the userId which you select at the time of
registration
Password Password Password
Sender Senderid You may have multiple senderIds at website but you
need to choose one
Sendto 9811xxxxxx,9812xxxxxx Write comma separated,10 digit mobile numbers. You
can send at the most 200 numbers in one go.
Message The text you want to send The text you want to send.

NOTE : Method of Post should always be "GET"

for example try to send this string from web browser

http://www.yourdomain.com/api/swsendSingle.asp?username=xxxx&password=xxxx&sender=sender
Id&sendto=919xxxx&message=hello

Page 3
API single message to multiple recipient

Variable Value Details

User Name loginId This is the userId which you select at the time of
registration

Password Password Password


Sender Senderid You may have multiple senderIds at website but you
need to choose one

Sendto 9811xxxxxx,9812xxxxxx Write comma separated,10 digit mobile numbers. You


can send at the most 200 numbers in one go.

Message The text you want to send The text you want to send.

NOTE : Method of Post should always be "GET"

for example try to send this string from web browser

http://www.yourdomain.com/api/swsend.asp?username=xxxx&password=xxxx&sender=senderId&se
ndto=919xxxx,919xxxx&message=hello

Page 4
To get the LIVE delivery report

Variable Value Details

User Name loginId This is the userId which you select at the time of registration

Password Password Password


Sender Senderid You may have multiple senderIds at website but you need to
choose one

Sendto 9811xxxxxx,9812xxxxxx Write comma separated,10 digit mobile numbers. You can send at
the most 200 numbers in one go.

Message The text you want to send The text you want to send.
dlrUrl The url where you want to http://yourServer_Url?logID=$logID$%26phNo=$phNO$%26resu
receive the delivery reports. lt=$result$

Explanation of the dlrUrl variable

server_Url : is the URL where u want to receive the report


This URL is create by you on your website.

The Text after (?) (the query String) wll remain same for all.

Finally the complete url to send SMS with delivery report will look something like :

http://www.yourdomain.com/api/swsend.asp?username=xxxx&password=xxxx&sender=senderId&se
ndto=919xxxx,919xxxx&message=hello&dlrUrl=http://yourServer_Url?logID=$logID$%26phNo=$p
hNO$%26result=$result$

Page 5
Check Balance

Variable Value Details

User Name loginId This is the userId which you select at the time of registration

Password Password Password

Post the above variables to http://www.yourdomain.com/api/checkbalance.asp

NOTE : Method of Post should always be "GET"


for example try to send this string from web browser

http://www.yourdomain.com/api/checkbalance.asp?username=xxxx&password=xxxx

Page 6
1.ASP.NET (C#) CODE

String varUserName=username;

String varPWD=password;

String varSenderID=senderID;

String varPhNo=”9811xxxxxx,9812xxxxxx”;

String varMSG=”message to send”;

String
varUrl=”http://www.yourdomain.com/api/swsend.asp?username=”+varUserName+“&password=”+va
rPWD+”&sender=”+varSenderID+“&sendto=”+varPhNo+“&message=”+varMSG;

WebClientwc=new WebClient();

String responseFromServer=wc.DownloadString(varUrl);

Page 7
2.ASP CLASSIC CODE

varUserName=username

varPWD=password

varSenderID=senderID

varPhNo=”9811xxxxxx,9812xxxxxx”

varMSG=”message to send”

varUrl=”http://www.yourdomain.com/api/swsend.asp?username=”&varUserName& “&password=”
&varPWD& ”&sender=” &varSenderID& “&sendto=” &varPhNo& “&message=” &varMSG

Set objXmlhttp = Server.CreateObject("msxml2.ServerXMLHTTP")

objXmlhttp.setTimeouts 16000, 16000, 16000, 16000

objXmlHTTP.open "GET", varUrl ,false

objXmlHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"

objXmlhttp.send(NULL)

responseFromServer=objXmlHttp.responseText

response.write responseFromServer

Page 8
3.JAVA CODE

importjava.io.BufferedReader;

importjava.io.InputStreamReader;

importjava.io.OutputStreamWriter;

importjava.net.HttpURLConnection;

import java.net.URL;

importjava.net.URLEncoder;

importjava.util.Date;

public class SMSSend {

public static void main(String[] args)

{ try {

Date mydate = new Date(System.currentTimeMillis());

varUserName=username

varPWD=password

varSenderID=senderID

varPhNo=”9811xxxxxx,9812xxxxxx”

varMSG=”message to send”

varUrl=”http://www.yourdomain.com/api/swsend.asp?username=”+varUserName+“&password=”+va
rPWD+”&sender=”+varSenderID+“&sendto=”+varPhNo+“&message=”+varMSG

URL url = new URL(varUrl);

HttpURLConnection conn = (HttpURLConnection)url.openConnection();

conn.setRequestMethod("GET");

conn.setDoOutput(true);

conn.setDoInput(true);

Page 9
conn.setUseCaches(false);

conn.connect();

BufferedReaderrd = new BufferedReader(new InputStreamReader(conn.getInputStream()));

String line;

StringBuffer buffer = new StringBuffer();

while ((line = rd.readLine()) != null){

buffer.append(line).append("\n");}

System.out.println(buffer.toString());

rd.close();

conn.disconnect();}

catch(Exception e)

{e.printStackTrace();}

}}

Note: Required javax.servlet.jar and jdom.jar to execute ( downloadable from internet,add toclasspath
).

Page 10
4.PHP CODE

$varUserName=username

$varPWD=password

$varSenderID=senderID

$varPhNo=”9811xxxxxx,9812xxxxxx”

$varMSG=”message to send”

$url=" http://www.yourdomain.com/api/swsend.asp";

$data="username=”.$varUserName.“&password=”.$varPWD.”&sender=”.$varSenderID.“&sendto=”.
$varPhNo.“&message=”.$varMSG;

postData($url,$data);

functionpostdata($url,$data)

//The function uses CURL for posting data to server

$objURL = curl_init($url);

curl_setopt($objURL, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($objURL,CURLOPT_POST,1);

curl_setopt($objURL, CURLOPT_POSTFIELDS,$data);

$retval = trim(curl_exec($objURL));

curl_close($objURL);

return $retval;

Page 11
5. MS SQL CODE

DECLARE @objint

DECLARE @response nvarchar(200)

DECLARE @URL varchar(max)

SET @msgTextTemp=REPLACE(@msgTextTemp,'&','%26')

SET @msgTextTemp=REPLACE(@msgTextTemp,'%','%25')

SET @msgTextTemp=REPLACE(@msgTextTemp,CHAR(13),CHAR(10))

SET
@URL=http://www.yourdomain.com/api/swsend.asp?username=xxxx&password=xxxx&sender=##se
nderID##&sendto=##phNo##&message=##msg##

SET @URL=replace(@URL,'##phNo##',@phNo)

SET @URL=replace(@URL,'##senderID##',@senderID)

SET @URL=replace(@URL,'##msg##',@msgTextTemp)

Exec sp_OACreate 'MSXML2.ServerXMLHttp',@obj OUTPUT

Exec sp_OAMethod @obj, 'Open',NULL,'GET',@URL,false

Exec sp_OAMethod @obj,'send'

Exec sp_OAGetProperty @obj,'responseText',@response OUTPUT

PRINT @response

Exec sp_OADestroy @obj

Page 12

Potrebbero piacerti anche