Jump to content

SMS Code Works In Exe But Not DLL Application


M.Ammar

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...