M.Ammar Posted September 15, 2019 Share Posted September 15, 2019 Hi All, I use this code below to send SMS Via Local SMS Service Provider, it is working fine if the application running as stand alone Application.exe but when I run in production (IIS + HyperServer.Dll + Application.exe) it never works, I don't understand the code fully as I got it from the service provider any idea why? function TmodSMS.SendSMS(numbers, URL, msgBody, Password: string): string; const ResponseSize = 1024; var hSession, hURL : HInternet; Request : string; ResponseLength : Cardinal; begin msgBody := Trim(msgBody); hSession := InternetOpen('DrBob42', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0); try Request := Format(URL, [numbers, HttpEncode(msgBody), Password]); 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 finally InternetCloseHandle(hSession) end; end; Regards Quote Link to comment Share on other sites More sharing options...
mierlp Posted September 15, 2019 Share Posted September 15, 2019 Hi The example from drBob is very old..try my example where i use also a sms provider bulksms and messagebird You have to use the provided api link from you provider. I didn't try it using it as a .dll http://forums.unigui.com/index.php?/topic/11892-here-an-example-for-sending-sms/ 1 Quote Link to comment Share on other sites More sharing options...
M.Ammar Posted September 16, 2019 Author Share Posted September 16, 2019 12 hours ago, mierlp said: Hi The example from drBob is very old..try my example where i use also a sms provider bulksms and messagebird You have to use the provided api link from you provider. I didn't try it using it as a .dll http://forums.unigui.com/index.php?/topic/11892-here-an-example-for-sending-sms/ I Wanted To thank you, your code works perfectly I only needed to change some code to work with my provider Here is the code after change function TmodSMS.SendSMS(SenderMobile,numbers, URL, msgBody, Password, sender: string): string; var Data: TStringlist; begin Data := TStringList.Create; // Assign username // Data.Add('username=' + USERNAME); Data.Add('mobile=' + SenderMobile); // Assign password Data.Add('password=' + Password); // Assign the entered phone number where to send the message Data.Add('numbers=' + numbers); Data.Add('sender='+ sender); // Assing the entered message Data.Add('msg=' + HttpEncode(msgBody)); Data.Add('applicationType=68'); Data.Add('lang=3'); // return code, Result for SMS Sending Result := IdHTTP1.Post(URL, Data); Data.Free; end; Best Regards Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.