asapltda Posted January 29, 2021 Share Posted January 29, 2021 Good morning gentlemen, at the bottom I can send a text message to the user, using the browser url line. How you could send that data to the user using rest avoiding displaying the user and password of the text message provider. Thank you https://api101.hablame.co/api/sms/v2.1/send/?account=10010651&apiKey=KtAL0wS1lk0KvDJckxsv9sDodFpKkc&token=ae3b827577725de9dd0d461b682cbe8f&toNumber=573015465902&sms=www.logisticasoft.net Quote Link to comment Share on other sites More sharing options...
mierlp Posted January 29, 2021 Share Posted January 29, 2021 Here an example for sending SMS - Sample Projects - uniGUI Discussion Forums Quote Link to comment Share on other sites More sharing options...
asapltda Posted January 31, 2021 Author Share Posted January 31, 2021 Thx Mierlp, Code test supplied // SEND TEXT MESSAGE VIA OPERATOR hablame.co function enviarmensaje(p_telefono, P_mensaje:string; var P_MsgError:string) :boolean; const // URL PROVEEDOR URL = 'https://api101.hablame.co/api/sms/v2.1/send/'; URLBackup = 'https://api102.hablame.co/api/sms/v2.1/query/smsId/'; var Data: TStringlist; // returnCode: string; w_mensaje : string; IdHTTP1:TidHTTP; // <---- USES IdHTTP W_STR:string; w_int:Integer ; begin IdHTTP1 := TIdHTTP.Create(nil); w_mensaje := TimeToStr(now) + '->' + P_mensaje; Data := TStringList.Create; Data.Add('account=' + '10010651'); Data.Add('apiKey=' + 'YtAL0wS1lk0KvDJckxsv9sDodFpyYkc'); Data.Add('token=' + 'ae3b827512325de9dd0d461b268cbe8f'); Data.Add('toNumber=' + p_telefono); Data.Add('sms=' + w_mensaje); Data.Add('sc=' + '899991'); // Show return code P_MsgError := IdHTTP1.Post(URL, Data); // <----- answer w_int :=Pos('1x000', P_MsgError); // <--- message sent successfully if w_int > 0 then Result:=True else Result:=False; Data.Free; IdHTTP1.Free ; end; Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted February 1, 2021 Share Posted February 1, 2021 Thank you aspltda, When trying your code i get : Ofcourse i add the two SSL files ( libeay32.dll + ssleay32.dll ) Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted February 1, 2021 Share Posted February 1, 2021 I was thinking wrongly, that your solution was for free :) In fact, you have to create an acount hablame.co and pay. For me, i am using an other alternative : 1. Buy nrComm Library from DeepSoftware: https://www.deepsoftware.com/nrcomm/ 2. Buy 3G GSM USB Modem (Amazone, ebay,...) 3. Buy a 3G Cheap from your local Phone Operator Use this combination to send economic SMS. 1 Quote Link to comment Share on other sites More sharing options...
adragan Posted February 1, 2021 Share Posted February 1, 2021 There are service providers that send SMS-s from a REST messages. I'm using this approch. From application I format a REST message according to the provider API using RestRequest, RestReponse etc. Each provider has a different API so code examples are of no use. I thought of Abaksoft solution at first but there was no GSM signal in the datacenter and sharing a modem USB port between more users has it's chalanges / complications. Not impossible thou. Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted February 2, 2021 Share Posted February 2, 2021 On 2/1/2021 at 9:00 AM, adragan said: I thought of Abaksoft solution at first but there was no GSM signal in the datacenter and sharing a modem USB port between more users has it's chalanges / complications. Not impossible thou. Hello Adragan, There is a solution to this : Indeed, you cannot physically install the GSM Modem in an inaccessible VPS. But we can install it on our server at the office. For everything works well, you need: A. VPS Side : A.1 Write (live) on a Table, all the messages and PhoneNumbers. A.2 Create a service that communicates with our server (Office). This Service will send these data in real time to a locally Table (Office). B. Office Side : B1. Read this Data and send them via our GSM Modem Regards... Quote Link to comment Share on other sites More sharing options...
asapltda Posted February 14, 2021 Author Share Posted February 14, 2021 Good afternoon Mr AbakaSoft, the solution is very interesting, you could share the name of the manufacturer, model and price of the gsm modem I buy from, this soluccion and if possible the band you use to send messages tks Quote Link to comment Share on other sites More sharing options...
mierlp Posted February 15, 2021 Share Posted February 15, 2021 Hi I use the same solution as Abakasoft. I have a database table with standard messages. A standard message contains variables that can be used in the message. This will look like this for example. This is typed in a dbmemo field. Dear [DRIVER], please move your vehicle with license plate [NUMBER PLATE] directly to P3. In the screen where you can send an SMS message you can choose from the standard messages. The data of the variable is replaced with data from a database to personalize it. This will look like this: Dear Peter van Mierlo, please move your vehicle with license plate AA-BB-123 to P3 immediately. The merged SMS message is stored in its entirety in a separate database for sending. Another process checks the database and sends the message and moves it to an archive. Keep in mind the maximum number of characters that you can send in 1 SMS. This is often 160 characters. If you are above this, a second text message will be charged or your credit will be deducted. See attached screenshot...it's dutch but you got a idea how it looks. This is a win32 application, but i have something simular with unigui. Also the user can set the priority to high or normal for the sms message. The difference is when using priority high the message directly showed on the screen without opening you're sms app on the phone. Priority normal you have to open you're sms app to view the complete message. You don't need a expensive gsm modem. Take a look at www.aliexpress.com and search gsm modem of wavecom modem. https://www.aliexpress.com/item/32703915582.html?spm=a2g0o.productlist.0.0.1a953654pbk4IZ&algo_pvid=d4071e00-3e66-482c-b36b-11325bca75cd&algo_expid=d4071e00-3e66-482c-b36b-11325bca75cd-1&btsid=0b0a050b16134312210398176e9ee0&ws_ab_test=searchweb0_0,searchweb201602_,searchweb201603_ Check the modem gsm band if it's supported in your country. You buy a modem for about € 25-€ 30. Buy a simcard with you're phone provider in your country and you are ready to go. Best is to use a usb modem...mostly you don't need a driver. I use several wavecom modems for sending sms messages from desktop and uniGui applications without problems. When a customer has internet on his event location they can use the internet variant but can also use a connected modem. When using internet providers you can create sub-accounts per customer and set the sender-ID (company name or something else.) The person who receives a sms message also sees the sender-ID...for example the company name. 1 Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted February 16, 2021 Share Posted February 16, 2021 On 2/14/2021 at 10:44 PM, asapltda said: Good afternoon Mr AbakaSoft, ...you could share the name of the manufacturer, model and price of the gsm modem I buy from, this soluccion and if possible the band you use to send messages tks Good morning Mr. Asapltda, I am using ZTE MF831 / USB GSM - You have to buy an Original unlocked key - Download its driver from ZTE to see it as COM on Device Manager. See my sample with nrComm Lib (attached file). Have fun... SMS_via_GSM.7z Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted February 16, 2021 Share Posted February 16, 2021 21 hours ago, mierlp said: Great Peter ! +1 Quote Link to comment Share on other sites More sharing options...
Ron Posted February 23, 2021 Share Posted February 23, 2021 function TCompObject.SendSMSMessage(number, msg:string):boolean; const cUSER_AGENT = 'Mozilla/4.0 (MSIE 6.0; Windows NT 5.1)'; var authtoken, url, SID, StatusText: string; aResponse: TStringStream; aParams:TStringList; mHTTP:TidHTTP; LHandler: TIdSSLIOHandlerSocketOpenSSL; fullCallbackURL, ResponseText:string; begin result:=false; fullCallbackURL:='http://www.mydomain.com/'+callbackURL; try mHTTP:=TIdHTTP.Create(nil); mHTTP.Request.BasicAuthentication:=true; mHTTP.Request.Username:=accountsid; mHTTP.Request.Password:=accountpw; url := Format('https://%s/%s/Accounts/%s/Messages/', [apiurl, apiversion, accountsid]); aParams := TStringList.Create ; try LHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil); aParams.add('From='+alfanumID); aParams.add('To='+number); aParams.add('Body='+msg); aParams.add('StatusCallback='+fullCallbackURL); aResponse := TStringStream.Create; try mHTTP.IOHandler:=LHandler; mHTTP.ReadTimeout:=15000; mHTTP.Post(url, aParams, aResponse); finally ResponseText := aResponse.DataString; LHandler.Free; end; finally aParams.Free; aResponse.Free; mHTTP.Free; end; except on E:Exception do logMsg('SendSMSMessage Exception: '+ E.Message) end; //get SID and status SID:=getSID(ResponseText); statusText:=getStat(ResponseText); if pos('queued', ResponseText)<>0 then begin Result:=true; logMsg('SMS Message sent to: '+number+', msg: '+msg); end else Syslog('MainModule: SMS Sending Error - response: '+responseText); end; I use Twilio.com, and they have a REST service where you POST the message, using basicauth and SSL. 1 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.