Requesting data with a http-request from an URL is the basic 1st step the JCI Plugins do. The JCI PRO Plugin is very flexible in doing this.
Setup a http-request means:
How is the request done? Check the API what method GET / POST / PUT is expected. Then usually the CURL-variant is working. If not you may try the other methods.
Curloptions” in the JCI PRO Template a CURL-Request can be build for any needs.
PHP-RAW and WP send fixed headers. CURL is very flexible here.
Additional Info when using POST
Who many seconds for loading url till timeout?
Set the cachetime for this URL to n seconds, regardless of the settings in the plugin-option, even when caching is switched off there.
Authentication: API-Keys, oAuth2 etc.
Many APIs require additional info about the asking user. Usual ways are (see the manual of the API you want to ask what it is expecting):
- API-Key as GET-Parameter:
Add to the API-URL something like
- Sending the API-Key in the request-header, see the API-manual:
Usa a JCI-Template and add at CURLOPTIONS something like
A very common way is sending authentication-data (somehow a username and password) to the API and the APIs answers with a Token. This Token is valid for some time and has to be sent for the real API-request about data. See here how this is done:
Get Token – Get Data with the Token
- There are many more ways API checking the Authentication
Result of the request: Answer of the API
Depending on the API the result of the request is some data, usally text-data formatted as JSON, XML, CSV…
Handling XML and CSV
With the Shortcode-Options
inputtype=xml or =csv
you can convert XML / CSV into JSON.