Note: If message contains special charcaters like space,@,- etc then please encode the message before passing it into the API call.
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Properties;
public class CallSmscApi {
public CallSmscApi() {
}
/* 1 Create a URL.
2 Retrieve the URLConnection object.
3 Set output capability on the URLConnection.
4 Open a connection to the resource.
5 Get an output stream from the connection.
6 Write to the output stream.
7 Close the output stream.
*/ public static void main( String[] args) throws Exception{
String postData="";
String retval = "";
//give all Parameters In String String User ="User_Name";
String passwd = "Password";
String mobilenumber = "Mno1,Mno2,,,,Mnon";
String message = "SMS MEssage";
String sid = "Sender_Id";
String mtype = "N";
String DR = "Y";
postData += "User=" + URLEncoder.encode(User,"UTF-8") + "&passwd=" + passwd + "&mobilenumber=" + mobilenumber + "&message=" + URLEncoder.encode(message,"UTF-8") + "&sid=" + sid + "&mtype=" + mtype + "&DR=" + DR;
URL url = new URL("http://smscountry.com/SMSCwebservice_Bulk.aspx");
URL url = new URL("http://smscountry.com/SMSCwebservice_Bulk.aspx");
HttpURLConnection urlconnection = (HttpURLConnection) url.openConnection();
// If You Are Behind The Proxy Server Set IP And PORT else Comment Below 4 Lines
//Properties sysProps = System.getProperties();
//sysProps.put("proxySet", "true");
//sysProps.put("proxyHost", "Proxy Ip");
//sysProps.put("proxyPort", "PORT");
urlconnection.setRequestMethod("POST");
urlconnection.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
urlconnection.setDoOutput(true);
OutputStreamWriter out = new OutputStreamWriter(urlconnection.getOutputStream());
out.write(postData);
out.close();
BufferedReader in = new BufferedReader( new InputStreamReader(urlconnection.getInputStream()));
String decodedString;
while ((decodedString = in.readLine()) != null) {
retval += decodedString;
}
in.close();
System.out.println(retval);
}
}
' This is ASP sample code
<%@ ENABLESESSIONSTATE = False %>
<% option explicit %>
<%
Dim objXMLHTTP, sRemoteURL,posturl
'Create & initialize the XMLHTTP object
Set objXMLHTTP = Server.CreateObject("Msxml2.ServerXMLHTTP.6.0")
sRemoteURL = "http://www.smscountry.com/SMSCwebservice_Bulk.aspx"
'Open the connection to the remote server
objXMLHTTP.Open "POST", sRemoteURL
objXMLHTTP.setProxy 2, "192.168.1.210:6666"'If you are behind proxy please mention the proxy ip with port. Or just comment this particular line...
objXMLHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
posturl = "User=xxxx&passwd=xxxx&mobilenumber=919xxxxxxxxx&message=xxxx&sid=xxxx&mtype=N&DR=Y"
objXMLHTTP.setRequestHeader "Content-Length",LEN(posturl)
'Send the request to the eProcessingNetwork Transparent Database Engine
objXMLHTTP.Send posturl
'store the response response.Write (objXMLHTTp.responseText)
%>
using System;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SMSCAPI obj = new SMSCAPI();
string strPostResponse;
strPostResponse = obj.SendSMS("UserName", "XXXXX", "919XXXXXXXXX", "hi");
Response.Write("Server Response " + strPostResponse);
}
}
<?php
//Please Enter Your Details
$user="XXXXXX"; //your username
$password="XXXXXX"; //your password
$mobilenumbers="919XXXXXXXXX"; //enter Mobile numbers comma seperated
$message = "test messgae"; //enter Your Message
$senderid="SMSCountry"; //Your senderid
$messagetype="N"; //Type Of Your Message
$DReports="Y"; //Delivery Reports
$url="http://www.smscountry.com/SMSCwebservice_Bulk.aspx";
$message = urlencode($message);
$ch = curl_init();
if (!$ch){die("Couldn't initialize a cURL handle");}
$ret = curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt ($ch, CURLOPT_POSTFIELDS,
"User=$user&passwd=$password&mobilenumber=$mobilenumbers&message=$message&sid=$senderid&mtype=$messagetype&DR=$DReports");
$ret = curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//If you are behind proxy then please uncomment below line and provide your proxy ip with port.
// $ret = curl_setopt($ch, CURLOPT_PROXY, "PROXY IP ADDRESS:PORT");
$curlresponse = curl_exec($ch); // execute
if(curl_errno($ch))
echo 'curl error : '. curl_error($ch);
if (empty($ret)) {
// some kind of an error happened
die(curl_error($ch));
curl_close($ch); // close cURL handler
} else {
$info = curl_getinfo($ch);
curl_close($ch); // close cURL handler
//echo "
";
echo $curlresponse; //echo "Message Sent Succesfully" ;
}
?>
require 'net/http'
require 'uri'
class SmscAPI
def initialize()
@user="USERNAME"; #your username
@password="PASSWORD"; #your password
@mobilenumbers="MOBILEMUMBERS"; #enter Mobile numbers comma seperated
@message ="Message"; # "MESSAGE"; #enter Your Message
@senderid="SENDERID"; #Your senderid
@messagetype="N"; #Type Of Your Message
@DReports="Y"; #Delivery Reports
end
def sendSMS()
url=URI.parse("http://www.smscountry.com/SMSCwebservice_Bulk.aspx");
request = Net::HTTP::Post.new(url.path)
request.set_form_data({'user'=>@user, 'passwd'=>@password, 'mobilenumber'=>@mobilenumbers, 'message'=>@message, 'senderid'=>@senderid, 'mtype'=>@messagetype, 'DR'=>@DReports})
response = Net::HTTP.new(url.host, url.port).start {|http| http.request(request) }
# If U are Behind The Proxy Comment Above Line And Uncomment Below Line, Give The Proxy Ip & Port
#response = Net::HTTP::Proxy("PROXY IP", PROXYPORT).new(url.host, url.port).start {|http| http.request(request) }
case response
when Net::HTTPSuccess
puts response.body
else
response.body
response.error!
end
end
end
t = SmscAPI.new();
t.sendSMS();
SET DATE
BRITISH
LOCAL
oHttp
LOCAL
sUser
LOCAL
sPass
LOCAL
sFromDate && in MM/DD/YYYY format
LOCAL
sToDate && in MM/DD/YYYY format
LOCAL
sKeywordSMSC
LOCAL
SKeywordResult
sUser = "XYZ"
sPass = "XYZ"
sFromDate = "06/01/2010"
sToDate = "06/05/2010"
sKeywordSMSC = "http://www.smscountry.com/apigetinbox.asp?user=" + sUser + "&passwd=" + sPass + "&FromDate=" + sFromDate + "&todate=" + sToDate
oHTTP = CREATEOBJECT('WinHttp.WinHttpRequest.5.1')
WITH
oHttp
.Open("GET", sKeywordSMSC)
.Send()
? .Status, .StatusText
? .GetAllResponseHeaders()
STRTOFILE(.ResponseText, "response.txt") MODI FILE response.txt NOWAIT
ENDWITH
import urllib,urllib.request,urllib.parse
class SendSms:
def __init__(self,mobilenumber,message):
url = "http://www.smscountry.com/smscwebservice_bulk.aspx"
values = {'user' : 'XXXX',
'passwd' : 'XXXX',
'message' : message,
'mobilenumber':mobilenumber,
'mtype':'N',
'DR':'Y'
}
data = urllib.parse.urlencode(values)
data = data.encode('utf-8')
request = urllib.request.Request(url,data)
response = urllib.request.urlopen(request)
print (response.read().decode('utf-8'))
'This is a ASP.Net using VB.Net as CodeBehind
Imports Class1 'Include this class file to send sms. Click the Downloads link beside to downloads this file.
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim obj As New Class1
'If your message includes special characters, then please use URLEncode method before passing the value of the message parameter.
'For Ex. HttpUtility.UrlEncode(message)
Dim strPostResponse As String = obj.SendSMS("UserName", "Password", "919XXXXXXXXX", "Message")
Response.Write("Server Response " & strPostResponse)
End Sub
End Class
Crete function SMSC_Send_Sms
(
@url varchar(8000)
)
returns varchar(8000)
as
BEGIN
DECLARE @win int
DECLARE @hr int
DECLARE @text varchar(8000)
EXEC @hr=sp_OACreate 'WinHttp.WinHttpRequest.5.1',@win OUT
IF @hr <> 0 EXEC sp_OAGetErrorInfo @win
EXEC @hr=sp_OAMethod @win, 'Open',NULL,'GET',@url,'false'
IF @hr <> 0 EXEC sp_OAGetErrorInfo @win
EXEC @hr=sp_OAMethod @win,'Send'
IF @hr <> 0 EXEC sp_OAGetErrorInfo @win
EXEC @hr=sp_OAGetProperty @win,'ResponseText',@text OUTPUT
IF @hr <> 0 EXEC sp_OAGetErrorInfo @win
EXEC @hr=sp_OADestroy @win
IF @hr <> 0 EXEC sp_OAGetErrorInfo @win
RETURN @text
END
--select dbo.SMSC_Send_Sms('http://www.smscountry.com/smscwebservice_bulk.aspx?user=XXX&passwd=XX&message=xxxxxxx&mobilenumber=91xxxxxxxxxx&sid=SMSC&mtype=N&dr=Y')
Steps to integrate SMSCountry Oracle API in Oracle System.
---------------------------------------------------------------
1) Download the SMSCountry_Oracle_API.plb file and copy .plb file from it into D drive.
3) In SqlPlus run below command
sql> @D:\SMSCountry_Oracle_API.plb;
4) You will see message as "package created" and "package body created".
5) Now to send SMS call function SendSMS as
a) Declare all variables as below and initialize them with your account details and sms parameters. Set Proxy_Str as "Your ProxyIP:Your Proxy port". If you don't have proxy then pass it as empty.
sql> VARIABLE Response VARCHAR2(500);
sql> VARIABLE username VARCHAR2(15);
sql> VARIABLE password VARCHAR2(15);
sql> VARIABLE mobile_numbers VARCHAR2(500);
sql> VARIABLE message VARCHAR2(500);
sql> VARIABLE Sender-ID VARCHAR2(15);
sql> VARIABLE Message_Type CHAR;
sql> VARIABLE Proxy_Str VARCHAR2(20);
b) Use any of below methods to call the SendSMS function.
sql> Call SMSCountry_Oracle_API.SendSMS(username, password, mobile_numbers,message,Sender-ID,Message_Type,Proxy_Str) into :Response;
sql> Print Response;
OR
select SMSCountry_Oracle_API.SendSMS(username, password, mobile_numbers,message,Sender-ID,Message_Type,Proxy_Str) from dual;
6) To check delivery status of the message, call GetDR function as:
a) Declare all variables as below and initialize them with your account details and Job-Id. Set Proxy_Str as "Your ProxyIP:Your Proxy port". If you don't have proxy then pass it as empty.
sql> VARIABLE Response VARCHAR2(500);
sql> VARIABLE username VARCHAR2(15);
sql> VARIABLE password VARCHAR2(15);
sql> VARIABLE SMS_Job_ID VARCHAR2(16);
b) b) Use any of below methods to call the GetDR function.
sql> Call SMSCountry_Oracle_API.GetDR(username, password, SMS_Job_ID,Proxy_Str) into :Response;
sql> Print Response;
OR
select SMSCountry_Oracle_API.SendSMS(username, password, SMS_Job_ID,Proxy_Str) from dual;

Contact Us

  • Telephone : 91-40-4747-5500
  • 91-40-3936-3900