Libcurl - CURL_DEFAULT_PROTOCOL
Publicado: Vie Oct 30, 2020 7:33 pm
Hey everybody!
First of all, this official forum is great! congratulations to the developer(os developers), thank you for all the effort in making our community bigger and stronger!
Well, I'm having some trouble with the libcurl, guys...
I'm trying to add a reCAPTCHA checkbox in my login page, and in reCAPTCHA's documentation it's required to use HTTPS as the default protocol...
So I first I decided to test it on postman and convert the request into code ( C - libcurl), that's the result:
As you can see it's pure C code, so I had to translate it to Harbour code like that:
The problem here is that there's no equivalent to CURLOPT_DEFAULT_PROTOCOL in hbcurl.ch, I already tried HB_CURLOPT_DEFAULT_PROTOCOL as you can see and many other ways, but it didn't work... does anybody has some suggestion?
First of all, this official forum is great! congratulations to the developer(os developers), thank you for all the effort in making our community bigger and stronger!
Well, I'm having some trouble with the libcurl, guys...
I'm trying to add a reCAPTCHA checkbox in my login page, and in reCAPTCHA's documentation it's required to use HTTPS as the default protocol...
So I first I decided to test it on postman and convert the request into code ( C - libcurl), that's the result:
Código: Seleccionar todo
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_URL, "https://www.google.com/recaptcha/api/siteverify?secret=6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe&response=03AGdBq26ZH0xDDgpzMEBr_u910XhZdjG6LfL796y9x2aOUIBbzNNPDho3SqxsVkn2-8gsKGq4HOBf3Ef0UEa0w4zDw_Ic0z-QHP-d9SFgklfsCsgl1E-GRzNWHR_vT_W0RkVamvVwJ0_a7yjiCpnM_qbqDDYK7Z_tXK_rzem7lQ6E9zF_duLMLbECB8J7dQ4p3rz2je81T1dhBGQqBJZuiXlfYsWxdem7rIAhydCiHm-1qZa8S50BEImBW3Pl5QRaLLhac4PX1_5_cI_EZ_q820hRt9hD71BnR5V6QNDCYDAt0mPrPe1rLowmrM772LmzQ8tRMyxukEdtNEPSwohQ1K3HcUKltM80ThRFrAQDkw5MwPDkYb5xwXckUFgK1zottFdiiUR5qDpxCyd9TjFhMo48srSaWco1xW7GgketOQcTga2RzDP1aZOcS3aYPdyKNZ0jDqCqFB8H3MSHMeM9yw10pe8Hfoj3fA");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
struct curl_slist *headers = NULL;
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
const char *data = "";
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
res = curl_easy_perform(curl);
}
curl_easy_cleanup(curl);
Código: Seleccionar todo
curl_global_init()
if ! empty( hCurl := curl_easy_init() )
curl_easy_setopt(hCurl, HB_CURLOPT_CUSTOMREQUEST, cHttp)
curl_easy_setopt(hCurl, HB_CURLOPT_URL, cUrl+"?"+cUrlFields)
curl_easy_setopt(hCurl, HB_CURLOPT_FOLLOWLOCATION, 1)
curl_easy_setopt(hCurl, HB_CURLOPT_PROTOCOLS,HB_CURLPROTO_HTTPS)
//curl_easy_setopt(hCurl, HB_CURLOPT_DEFAULT_PROTOCOL, "https")
curl_easy_setopt(hCurl, HB_CURLOPT_HTTPHEADER, NIL)
curl_easy_setopt(hCurl, HB_CURLOPT_POSTFIELDS, "")
curl_easy_setopt( hCurl, HB_CURLOPT_DL_BUFF_SETUP )
IF (nret:=curl_easy_perform( hCurl )) == 0
uValue = curl_easy_dl_buff_get( hCurl )
ENDIF
ENDIF
curl_global_cleanup()