Same HTTPRequest function as in SpiderBasic

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
MarcNL
User
User
Posts: 34
Joined: Mon Oct 25, 2010 4:04 pm

Same HTTPRequest function as in SpiderBasic

Post 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.
User avatar
falsam
Enthusiast
Enthusiast
Posts: 630
Joined: Wed Sep 21, 2011 9:11 am
Location: France
Contact:

Re: Same HTTPRequest function as in SpiderBasic

Post 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; 
?>

➽ Windows 11 64-bit - PB 6.0 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti

Sorry for my bad english and the Dunning–Kruger effect.
MarcNL
User
User
Posts: 34
Joined: Mon Oct 25, 2010 4:04 pm

Re: Same HTTPRequest function as in SpiderBasic

Post 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
User avatar
the.weavster
Addict
Addict
Posts: 1537
Joined: Thu Jul 03, 2003 6:53 pm
Location: England

Re: Same HTTPRequest function as in SpiderBasic

Post by the.weavster »

+1
A good complement to PB's excellent CGI commands.
Post Reply