I have successfully used libcurl for some processes, but for a new task, I have uncovered two issues:
curl_easy_setopt(hCurl, HB_CURLOPT_FOLLOWLOCATION, 1L). When trying to compile this, Harbour errors at the L ( in 1L ). This is a standard call.
curl_easy_setopt(hCurl, HB_CURLOPT_DEFAULT_PROTOCOL, "https"). This line errors because the hbcurl.ch does not have a listing for DEFAULT_PROTOCOL
These are two standard libcurl settings. My include file is from the latest version of Harbour supplied by FiveTech.
Any assistance would be appreciated.
I do have the right libraries linked in. I also have curl running smoothly on other tasks.
Thank you.
libcurl issues
- TimStone
- Posts: 2955
- Joined: Fri Oct 07, 2005 1:45 pm
- Location: Trabuco Canyon, CA USA
- Has thanked: 25 times
- Been thanked: 2 times
- Contact:
libcurl issues
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Re: libcurl issues
hi Tim,
you can use it with HB_CURLPROTO_HTTPS or HB_CURLPROTO_HTTP
there is not HB_CURLOPT_DEFAULT_PROTOCOL but HB_CURLOPT_PROTOCOLSTimStone wrote: curl_easy_setopt(hCurl, HB_CURLOPT_DEFAULT_PROTOCOL, "https").
you can use it with HB_CURLPROTO_HTTPS or HB_CURLPROTO_HTTP
greeting,
Jimmy
Jimmy
- TimStone
- Posts: 2955
- Joined: Fri Oct 07, 2005 1:45 pm
- Location: Trabuco Canyon, CA USA
- Has thanked: 25 times
- Been thanked: 2 times
- Contact:
Re: libcurl issues
Thank you
Sent from my iPhone using Tapatalk
Sent from my iPhone using Tapatalk
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
- TimStone
- Posts: 2955
- Joined: Fri Oct 07, 2005 1:45 pm
- Location: Trabuco Canyon, CA USA
- Has thanked: 25 times
- Been thanked: 2 times
- Contact:
Re: libcurl issues
Sometimes no matter how long you look at something, the answer just doesn't come, even when trying multiple approaches. This is one of them.
Still using libcurl:
This is a working format in straight c-libcurl:
Here is the same code in PHP-CURL:
and in straight cURL:
These are values for cPostFields to pass with curl_easy_setopt(hCurl, HB_CURLOPT_POSTFIELDS, cPostFields).
I've viewed a lot of samples, and tried approaches, but I cannot find a "Harbour friendly" format to write this string. Anyone confident on how to approach this ?
Thanks.
Still using libcurl:
This is a working format in straight c-libcurl:
Code: Select all | Expand
const char *data = "{\r\n \"transactionData\": {\r\n \"transactionType\": \"CreditSale\",\r\n \"method\": \"hostedFields\",\r\n \"submissionType\": \"automatic\",\r\n \"fields\": [\r\n {\r\n \"id\": \"base_amount\",\r\n \"value\": \"1.00\"\r\n },\r\n {\r\n \"id\": \"external_tran_id\",\r\n \"value\": \"ae898295-c8b8-4799-b2c1-88e5067be721\"\r\n },\r\n {\r\n \"id\": \"device_name\",\r\n \"value\": \"Flex-0554\"\r\n }\r\n ]\r\n }\r\n}";
Code: Select all | Expand
CURLOPT_POSTFIELDS =>'{
"transactionData": {
"transactionType": "CreditSale",
"method": "hostedFields",
"submissionType": "automatic",
"fields": [
{
"id": "base_amount",
"value": "1.00"
},
{
"id": "external_tran_id",
"value": ""
},
{
"id": "device_name",
"value": "Flex-0554"
}
]
}
}',
Code: Select all | Expand
--data-raw '{
"transactionData": {
"transactionType": "CreditSale",
"method": "hostedFields",
"submissionType": "automatic",
"fields": [
{
"id": "base_amount",
"value": "1.00"
},
{
"id": "external_tran_id",
"value": ""
},
{
"id": "device_name",
"value": "Flex-0554"
}
]
}
}'
I've viewed a lot of samples, and tried approaches, but I cannot find a "Harbour friendly" format to write this string. Anyone confident on how to approach this ?
Thanks.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
- cmsoft
- Posts: 1297
- Joined: Wed Nov 16, 2005 9:14 pm
- Location: Mercedes - Bs As. Argentina
- Been thanked: 2 times
Re: libcurl issues
Tim, no se si esto es lo que buscas, como generar ese json
Mira el archivo json.txt para ver el resultado si es el esperado
Espero te sea de utilidad
Code: Select all | Expand
#include "fivewin.ch"
function main()
LOCAL aData, aField, aRecord, aFields1 := {}, cJson
aData := hash()
aRecord := hash()
aRecord["transactionType"] = "CreditSale"
aRecord["method"] = "hostedFields"
aRecord["submissionType"] = "automatic"
aField := hash()
aField["id"] = "base_amount"
aField["value"] = "1.00"
AADD(aFields1,aField)
aField := hash()
aField["id"] = "external_tran_id"
aField["value"] = ""
AADD(aFields1,aField)
aField := hash()
aField["id"] = "device_name"
aField["value"] = "Flex-0554"
AADD(aFields1,aField)
aRecord["fields"] = aFields1
aData["transactionData"] = aRecord
cJson := hb_jsonEncode(aData,.f.)
memowrit("json.txt",cJson)
return nil
Espero te sea de utilidad
- TimStone
- Posts: 2955
- Joined: Fri Oct 07, 2005 1:45 pm
- Location: Trabuco Canyon, CA USA
- Has thanked: 25 times
- Been thanked: 2 times
- Contact:
Re: libcurl issues
I don't know that I have to encode the string as json. I have done that for other external systems where I'm passing data.
The examples I have provided were all being sent directly, as shown, to the website using "Postman". They work correctly. However, they are all variants from the Harbour code ( or FWH samples I see ) using libcurl.
Any other thoughts ?
Yes ... I can test this to see if it works but I think it's really just how I format the data similar to how the examples show, but that Harbour can actually use.
The examples I have provided were all being sent directly, as shown, to the website using "Postman". They work correctly. However, they are all variants from the Harbour code ( or FWH samples I see ) using libcurl.
Any other thoughts ?
Yes ... I can test this to see if it works but I think it's really just how I format the data similar to how the examples show, but that Harbour can actually use.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Re: libcurl issues
Try with
Code: Select all | Expand
Local cRequest
TEXT INTO cRequest
{
"transactionData": {
"transactionType": "CreditSale",
"method": "hostedFields",
"submissionType": "automatic",
"fields": [
{
"id": "base_amount",
"value": "1.00"
},
{
"id": "external_tran_id",
"value": ""
},
{
"id": "device_name",
"value": "Flex-0554"
}
]
}
}
ENDTEXT
? cRequest
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces