Page 1 of 1
Same HTTPRequest function as in SpiderBasic
Posted: Tue Sep 19, 2017 10:16 am
by MarcNL
SpiderBasic has a nice abstracted HTTP(s) request function HTTPRequest which I like to see in PureBasic also. This will make creating web service clients a bit more easier and less error-prone.
NB: With some manual work, and including a CURL lib, you may achieve the same, but that route should not be needed.
Re: Same HTTPRequest function as in SpiderBasic
Posted: Tue Sep 19, 2017 12:21 pm
by falsam
ReceiveHTTPMemory() ?
■ Code Purebasic
Code: Select all
;ReceiveHTTPMemory : Send & Receive Data
Global FirstName.s, Name.s, DataSend.s
;My data
FirstName = "John"
Name = "Do"
;Format data
DataSend + "&firstname=" + URLEncoder(FirstName) + "&name=" + URLEncoder(Name)
InitNetwork()
;Send data
*Buffer = ReceiveHTTPMemory("falsam.com/racal/hello.php?" + DataSend)
;Receive data
If *Buffer
Debug PeekS(*Buffer, -1, #PB_UTF8)
Else
Debug "Failed"
EndIf
■ Code Php hello.php
Code: Select all
<?php
$message="";
if (isset($_GET['firstname']) AND isset($_GET['name']))
{
$message = "Hello and welcome ".$_GET['firstname']." ".$_GET['name'];
}
echo $message;
?>
Re: Same HTTPRequest function as in SpiderBasic
Posted: Tue Sep 19, 2017 12:24 pm
by MarcNL
falsam wrote:ReceiveHTTPMemory() ?
I'm aware of that one, but it's limited to GET operations. I need more than that, like HTTPS (SSL), headers and body (POST/PUT/PATCH).
See the SpiderBasic docs:
http://www.spiderbasic.com/documentatio ... quest.html
Re: Same HTTPRequest function as in SpiderBasic
Posted: Tue Sep 19, 2017 5:53 pm
by the.weavster
+1
A good complement to PB's excellent CGI commands.