Print

PRO: Curloptions

If the API expects some Input besided the URL, then use a CURL-GET/POST/PUT-Request, where Curloptions come into the game.

In this way additional info can be sent to the API: CURL has many pre-defined options.

The Input-Field Curloptions in the JCI PRO Plugin is formatted the following way. By “CURLOPT_…=…;” you can put together the Option as needed:

CURLOPT_HTTPAUTH=CURLAUTH_BASIC;CURLOPT_TIMEOUT=30;CURLOPT_HTTPHEADER=a:{{urlparam.VAR1}}##c:d;CURLOPT_POSTFIELDS=e:f##{"g":"h"}##i:j

Often used CURLOPT_… options

  • Send header-data:
    CURLOPT_HTTPHEADER=a:{{urlparam.VAR1}}##c:d
  • Switch off https-check (use if certificate-errors occur):
    CURLOPT_SSL_VERIFYPEER=FALSE;CURLOPT_SSL_VERIFYSTATUS=FALSE;
  • The HTTP authentication method(s) to use. The options are: CURLAUTH_BASIC, CURLAUTH_DIGEST, CURLAUTH_GSSNEGOTIATE, CURLAUTH_NTLM, CURLAUTH_ANY, and CURLAUTH_ANYSAFE.
    CURLOPT_HTTPAUTH=...
  • The contents of the “User-Agent: ” header to be used in a HTTP request:
    CURLOPT_USERAGENT=my useragent
  • The full data to post in a HTTP “POST” operation. This parameter can either be passed as a urlencoded string like ‘para1=val1&para2=val2&…’ or as an array with the field name as key and field data as value. If value is an array, the Content-Type header will be set to multipart/form-data.
    CURLOPT_POSTFIELDS=e:f##{"g":"h"}##i:j
  • The maximum number of seconds to allow cURL functions to execute.
    CURLOPT_TIMEOUT=NUMBER

JCI adds CURLOPT_UPLOAD_POSTFIELDS

There is a JCI-proprietary Curl-option “CURLOPT_UPLOAD_POSTFIELDS“.
This can be used when you upload a file with a HTML-Uploadform for storing this file in ther WordPress-Medialibrary or send this Upload to an API. Example for the syntax:

CURLOPT_UPLOAD_POSTFIELDS={\"field1\": \"value field 1\", \"field 2\":\"value of field 2\", \"jciuploadfiles\": #BRO# { \"name\": \"FileUpload\", \"filename\":\"name-of-file\", \"store_upload_in_library\":\"yes\", \"library_file_name\":\"name-of-file-in-wp-lib\", \"uploadsamefilename\":\"no\" } #BRC# }
Was this article helpful?
0 out Of 5 Stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
5
How can we improve this article?
Please submit the reason for your vote so that we can improve the article.
On this page: