How to use hb_curl

How to use hb_curl

Postby tiagojbi » Fri Jan 15, 2021 1:30 pm

Hello everyone.
I would like to know how to reproduce this code on the line where it is:
CURLOPT_POSTFIELDS => array('username' => 'myUsername','password' => 'myPassword*'),
I don't know how to send the data type as an array in this situation. Could you help me?
I use hb_curl.lib to use CURL commands.

in FiveWin:
curlHandle := curl_easy_init()
curl_easy_setopt( curlHandle, HB_CURLOPT_URL, 'https://server.by.test.xxx')
curl_easy_setopt( curlHandle, HB_CURLOPT_DOWNLOAD )
curl_easy_setopt( curlHandle, HB_CURLOPT_DL_BUFF_SETUP )
curl_easy_setopt( curlHandle, HB_CURLOPT_ENCODING, '')
curl_easy_setopt( curlHandle, HB_CURLOPT_MAXREDIRS, 10)
curl_easy_setopt( curlHandle, HB_CURLOPT_TIMEOUT, 0)
curl_easy_setopt( curlHandle, HB_CURLOPT_FOLLOWLOCATION, 1)
curl_easy_setopt( curlHandle, HB_CURLOPT_HTTP_VERSION, 2)
curl_easy_setopt(curlHandle, HB_CURLOPT_POST, 1)
curl_easy_setopt( curlHandle, HB_CURLOPT_CUSTOMREQUEST, 'POST')
curl_easy_setopt( curlHandle, HB_CURLOPT_POSTFIELDS, 'username' => 'myUsername','password' => 'myPassword*')
cc1 := curl_easy_dl_buff_get( curlHandle )
nStatusCurl = curl_easy_getinfo(curlHandle, HB_CURLINFO_RESPONSE_CODE)
?nStatusCurl,strtran( htmltoansi( cc1 ), """, '"' )
//return received:
// 403, empty_username


in PHP:
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://server.by.test.xxx',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array('username' => 'myUsername','password' => 'myPassword*'),
));
//return received:
// 200, sucess

in CURL:
curl --location --request POST 'https://server.by.test.xxx' \
--form 'username="myUsername"' \
--form 'password="myPassword"'
tiagojbi
 
Posts: 16
Joined: Mon Mar 09, 2020 4:27 pm

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 80 guests