It is currently Sat Nov 25, 2017 2:59 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Same HTTPRequest function as in SpiderBasic
PostPosted: Tue Sep 19, 2017 10:16 am 
Offline
User
User

Joined: Mon Oct 25, 2010 4:04 pm
Posts: 31
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Same HTTPRequest function as in SpiderBasic
PostPosted: Tue Sep 19, 2017 12:21 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Sep 21, 2011 9:11 am
Posts: 577
Location: France
ReceiveHTTPMemory() ?

■ Code Purebasic
Code:
;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:
<?php
   $message="";
   
   if (isset($_GET['firstname']) AND isset($_GET['name']))
   {
      $message = "Hello and welcome ".$_GET['firstname']." ".$_GET['name'];
   }   
   echo $message;
?>

_________________

➽ Windows 10 - PB 5.45 LTS & PB 5.60

http://falsam.com & EasySprite.js
http://purebasic.chat - Code PureBasic
Image Pure Basic Francophone Community

Sorry for my bad english and the Dunning–Kruger effect.


Top
 Profile  
Reply with quote  
 Post subject: Re: Same HTTPRequest function as in SpiderBasic
PostPosted: Tue Sep 19, 2017 12:24 pm 
Offline
User
User

Joined: Mon Oct 25, 2010 4:04 pm
Posts: 31
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Same HTTPRequest function as in SpiderBasic
PostPosted: Tue Sep 19, 2017 5:53 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jul 03, 2003 6:53 pm
Posts: 1111
Location: England
+1
A good complement to PB's excellent CGI commands.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: Yahoo [Bot] and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye