Hello Pratik,
Please, read the next sample code in C/C++. The sample show how to send a MT
whit HTTP POST.
----------------------------------------------------Begin
sample-----------------------------------------------------------------------------------------------------------------
bool BearerMT::SendSMS(const String& FROM, const String& TO, const String&
BODY, const String& UDH, const String& SMPP)
{
bool ret = false;
String msg="";
String bodylen = "0";
String bodyX = BODY;
String error = "";
msg = "POST /cgi-bin/sendsms HTTP/1.1\r\nHost: 127.0.0.1\r\n";
if (UDH!="")
msg +="Content-type: application/octet-stream\r\n";
else
msg +="Content-type: text/plain\r\n";
msg+="X-Kannel-Username: ";
msg+=sendUser+"\r\n";
msg+="X-Kannel-Password: ";
msg+=sendPassword+"\r\n";
msg+="X-Kannel-From: ";
msg+=FROM+"\r\n";
msg+="X-Kannel-To: ";
msg+=TO+"\r\n";
if (UDH!="")
{
msg+="X-Kannel-UDH: ";
msg+= UDH;
msg+="\r\n";
}
msg+="X-Kannel-SMSC: ";
msg+= SMPP+"\r\n";
String temp;
try
{
bodylen = strlen(BODY.c_str());
msg+="Content-length: " + bodylen;
msg+="\r\nConnection: close\r\n\r\n" + BODY;
SocketOUT->Open();
SocketOUT->Connect(sendHost,sendPort); //port = SMSBOX Port, host =
SMSBOX IP
SocketOUT->Write(msg);
SocketOUT->Read(temp);
SocketOUT->Close();
error= "alertsms: MT Sended SMSC= " + SMPP + " To="+ TO + " Shortcode="
+ FROM + " UDH=" + UDH;
error = error + " Body=";
error = error + bodyX;
Log(LOG_INFO,error);
ret = true; //We send the SMS !! cool.
}
catch(Exception e)
{
//Uppss houston we have a problem
if (e.errn())
{
error+="alertsms: Errno=";
error+=e.errn();
error= " MT Failed SMSC= " + SMPP + " To="+ TO + " Shortcode=" +
FROM + " UDH=" + UDH;
error = error + " Body=";
error = error + bodyX;
}
}
return ret;
}
-----------------------------------------------End
sample---------------------------------------------------------------------------------------------------------
Best regards,
Alejandro Madero.
On Fri, Sep 10, 2010 at 10:24 AM, Rene Kluwen <[email protected]> wrote:
> Yes, it can do a Post method. See table 6-10 in the userguide:
>
>
>
> Example:
>
>
>
> SMSPush equivalent X-Kannel Header
>
> username X-Kannel-Username
>
> password X-Kannel-Password
>
> from X-Kannel-From
>
>
>
> *From:* [email protected] [mailto:[email protected]] *On
> Behalf Of *Pratik Shrestha
> *Sent:* Friday, 10 September, 2010 09:42
> *To:* [email protected]
> *Subject:* post-method support
>
>
>
> Dear All,
>
> I have a java application that post message to kannel gateway. When I use
> 'Get' method to send the message to kannel http (i.e.
> http://localhost:13131/cgi-bin/sendsms?username=**&password=**&to=**&text=**),
> it works well. But if I use 'Post' method to do the same job, I get HTTP
> error 400. What is the reason behind this? Is that kannel does not support
> post method?
>
> Regards,
> Pratik
>
--
Alejandro Madero G.
Dirección de Tecnología
Mobile Entertainment C.A.
Tel: +58416-6211236