Send External URL lazarus / 13-General ---------------------------------------------------------------------- blargman · 2007-04-03 04:02 I am trying to write a program that accesses a web API for an IP PBX.  I want to be able to send a URL to a browser, and then kill the browser immediately.  can this be done easily, or is there a way to do it without even opening a browser window. Any help is appreciated. Thanks in advance. Jeff ---------------------------------------------------------------------- Marc · 2007-04-03 09:54 ehm... whats the need for sending an URL, and the killing the browser ? ---------------------------------------------------------------------- blargman · 2007-04-03 15:47 I need to send a url to an api program that initiates a phone call on an IP PBX, but the page is not interactive, and serves no other function then just telling you if the command was completed successfully, so I really don't need the page to stay open. Thanks, Jeff ---------------------------------------------------------------------- theo · 2007-04-03 17:08 If I understand you correctly, you just need to send a request to a webserver? This can be done with a TCP/IP Library. For example Synapse: http://synapse.ararat.cz/ http://synapse.ararat.cz/docs/help/httpsend.html ---------------------------------------------------------------------- blargman · 2007-04-04 01:51 ok...  i tried this, but to no avail.  Please tell me what is wrong, as the documentation is not really all that good. Code: [Select] begin   data := 'admin=1&password=be00218c15b4a9c3452d2203fc5716a9&cmd=call& dial_as=218&dial_first=8327239619&dial_second=286';   {encodeURLelement(data);}   data := data+'d=286';     {because it doesn't get it all the first time}   ShowMessage(data);   THTTPSend.Create;   httpposturl('https://hou.phone.networklogic.net/api?',data,blah); end; I'm not sure what i'm supposed to be doing, but this is the code I came up with based on what I read in the wiki. Thanks, Jeff ---------------------------------------------------------------------- theo · 2007-04-04 09:20 Documentation is good enough, but it's not a tutorial about the HTTP Protocol. ;-) I don't think you need the HTTP POST Method for what you want. It looks more like the Server expects HTTP GET. And when using the "convenience" functions like HttpGetText you don't have to create THTTPSend yourself. So try the function: function HttpGetText(const URL: string; const Response: TStrings): Boolean; where everything is part of the URL as you would paste it in a browser's location field. The Result will be in the Response (TStrings). So try something like Respose:=TStringList.create; if HttpGetText('https://hou.phone.networklogic.net/api?admin=1&passwor d=be00...etc', Response) then //Do something with Response Response.free; Since the protocol ist "https", you need a SSL Plugin. Add for example ssl_openssl to the uses clause. Read more about this here: http://synapse.ararat.cz/wiki/index.php?page=SslPlugin ---------------------------------------------------------------------- blargman · 2007-04-05 21:58 here is the code I am using now: Code: [Select] procedure Tserver.Button4Click(Sender: TObject); var  blah:tstrings; begin   blah.create;   if HttpGetText('https://hou.phone.networklogic.net/api?admin=1&passw ord=be00218c15b4a9c3452d2203fc5716a9&cmd=call&dial_as=218&dial_first=2 09&dial_second=286',blah) then labelededit1.text := 'IT WORKS!!';   blah.free; end; but it still doesn't seem to be working.  I have the ssl_openssl in the uses statement, but it won't send out the URL properly.  I'm sure whatever it is that I am doing is stupid, but I would like to get it figured out. thanks, Jeff ---------------------------------------------------------------------- theo · 2007-04-06 09:14 There may be many reasons why it doesn't work for you, but it seems a bit hard to help you because: Your doing basic stuff wrong: blah.create;  is BS You're not even copying the things correctly I've shown already. It's written above: Respose:=TStringList.create; If you're on Windows, you'll probably have to install the "Crypting libraries for SSL/TLS/SSH". See link on the Synapse main page. ---------------------------------------------------------------------- blargman · 2007-04-07 02:23 ok....     PLEASE EXCUSE MY STUPIDITY! I can not seem to get this to work.  All I am trying to do is send a URL out to the web.  As soon as the URL is accessed, I no longer need anything from it, No response or anything. I'm using HTTPS and I have the Certificate installed on the PC that I am writing the code on.  I downloaded the Cryptic Libs, but really couldn't figure out what the hell to do with them.  I added the ssl_openssl to my uses statement, but not sure what I'm supposed to be doing with that. What am I missing?  What is it that my dumb a$$ is not doing.  I really want to learn this, but evidently I can't find documentation that is dummied up enough for my retarded self to understand. ---------------------------------------------------------------------- theo · 2007-04-07 09:38 Download the Openssl-0.9.8a-Win32.zip from http://synapse.ararat.cz/files/crypt/ and extract the DLLs to the Application- or System folder. ---------------------------------------------------------------------- blargman · 2007-04-09 18:06 theo, Sorry for getting frustrated.  I do appreciate your patience with me, and all your help. I have finally gotten this part of my app to work, and I would like to commend you for your knowledge. Thanks, Jeff