Sathish R
asked on
How to send sms using Delphi code
I have used 3 set of codes(where I used Indy10.6.2 component), which doesn't show any errors, but i can't able to send SMS through the code. Please help me to send me the Sms through Delphi code
The code which I used is...
const
URL = 'https://api.bulksmsgateway.in/send/?username=****&hash=****&sender=TXTLCL&numbers=9198........&message=HISUNDAR';
//URL = 'https://api.textlocal.in/send/?username=*****&hash=******&sender=TXTLCL&numbers=9198...&message=HISUNDAR';
ResponseSize = 1024;
var
hSession, hURL: HInternet;
Request: String;
ResponseLength: Cardinal;
begin
hSession := InternetOpen('TEST', INTERNET_OPEN_TYPE_PRECONF IG, nil, nil, 0);
try
Request := Format(URL,[Username,Passw ord,Sender ,Numbers,H ttpEncode( Message1)] );
hURL := InternetOpenURL(hSession, PChar(Request), nil, 0,0,0);
try
SetLength(Result, ResponseSize);
InternetReadFile(hURL, PChar(Result), ResponseSize, ResponseLength);
SetLength(Result, ResponseLength);
finally
InternetCloseHandle(hURL)
end;
showmessage(result);
finally
InternetCloseHandle(hSessi on)
end
var
http : TIdHTTP;
IdSSL : TIdSSLIOHandlerSocketOpenS SL;
begin
http := TIdHTTP.Create(nil);
IdSSL := TIdSSLIOHandlerSocketOpenS SL.Create( nil);
try
Http.ReadTimeout := 30000;
Http.IOHandler := IdSSL;
IdSSL.SSLOptions.Method := sslvTLSv1;
Http.Request.BasicAuthenti cation := True;
// IdSSL.SSLOptions.Method := sslvTLSv1;
//IdSSL.SSLOptions.Method := sslvTLSv1;
// http.Get('https://www.smsgatewayhub.com/api/mt/SendSMS?APIKey=B215dPone0yVIJU2QDH&senderid=TESTIN&channel=2&DCS=0&flashsms=0&number=9195.....&text=test message&route=1');
http.Get('http://login.bulksmsgateway.in/sendmessage.php?user=****&password=****&mobile=95661....&message=Good Morning&sender=PRAPUS&type =3 ');
finally
http.Free;
end;
var
lHTTP: TIdHTTP;
lParamList: TStringList;
lResult: String;
IdSSL : TIdSSLIOHandlerSocketOpenS SL;
begin
lParamList := TStringList.Create;
lParamList.Add('username=* ***');
lParamList.Add('password=* ***');
lParamList.Add('msgtext=He llo World');
lParamList.Add('originator =TestAccou nt');
lParamList.Add('phone=+919 5....');
lParamList.Add('showDLR=0' );
lParamList.Add('charset=0' );
lParamList.Add('msgtype=') ;
lParamList.Add('provider=b ulksmsgate way.in');
lHTTP := TIdHTTP.Create(nil);
try
lResult := lHTTP.Post('http://login.bulksmsgateway.in/sendmessage.php?', lParamList);
//WriteLn(lResult);
// Readln;
finally
FreeAndNil(lHTTP);
FreeAndNil(lParamList);
end;
The code which I used is...
const
URL = 'https://api.bulksmsgateway.in/send/?username=****&hash=****&sender=TXTLCL&numbers=9198........&message=HISUNDAR';
//URL = 'https://api.textlocal.in/send/?username=*****&hash=******&sender=TXTLCL&numbers=9198...&message=HISUNDAR';
ResponseSize = 1024;
var
hSession, hURL: HInternet;
Request: String;
ResponseLength: Cardinal;
begin
hSession := InternetOpen('TEST', INTERNET_OPEN_TYPE_PRECONF
try
Request := Format(URL,[Username,Passw
hURL := InternetOpenURL(hSession, PChar(Request), nil, 0,0,0);
try
SetLength(Result, ResponseSize);
InternetReadFile(hURL, PChar(Result), ResponseSize, ResponseLength);
SetLength(Result, ResponseLength);
finally
InternetCloseHandle(hURL)
end;
showmessage(result);
finally
InternetCloseHandle(hSessi
end
var
http : TIdHTTP;
IdSSL : TIdSSLIOHandlerSocketOpenS
begin
http := TIdHTTP.Create(nil);
IdSSL := TIdSSLIOHandlerSocketOpenS
try
Http.ReadTimeout := 30000;
Http.IOHandler := IdSSL;
IdSSL.SSLOptions.Method := sslvTLSv1;
Http.Request.BasicAuthenti
// IdSSL.SSLOptions.Method := sslvTLSv1;
//IdSSL.SSLOptions.Method := sslvTLSv1;
// http.Get('https://www.smsgatewayhub.com/api/mt/SendSMS?APIKey=B215dPone0yVIJU2QDH&senderid=TESTIN&channel=2&DCS=0&flashsms=0&number=9195.....&text=test message&route=1');
http.Get('http://login.bulksmsgateway.in/sendmessage.php?user=****&password=****&mobile=95661....&message=Good Morning&sender=PRAPUS&type
finally
http.Free;
end;
var
lHTTP: TIdHTTP;
lParamList: TStringList;
lResult: String;
IdSSL : TIdSSLIOHandlerSocketOpenS
begin
lParamList := TStringList.Create;
lParamList.Add('username=*
lParamList.Add('password=*
lParamList.Add('msgtext=He
lParamList.Add('originator
lParamList.Add('phone=+919
lParamList.Add('showDLR=0'
lParamList.Add('charset=0'
lParamList.Add('msgtype=')
lParamList.Add('provider=b
lHTTP := TIdHTTP.Create(nil);
try
lResult := lHTTP.Post('http://login.bulksmsgateway.in/sendmessage.php?', lParamList);
//WriteLn(lResult);
// Readln;
finally
FreeAndNil(lHTTP);
FreeAndNil(lParamList);
end;
Where you call https site - you should implement TIdSSLIOHandlerSocketOpenS SL, for common http - you don't need it.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.