PRO: API Zippopotamus, Shortcode-Parameter httpstatuscodemustbe200

The API gives Citynames and Coorindates to a Zipcode. The JCI-PRO-Plugin can use that for a “Zipcode to City-Search”.

This done this way:

Examples: Houston, US, TX | Munich, DE, Germany

1 .JCI-Shortcode:

httpstatuscodemustbe200=no tells the plugin to accept also non-ok-API-answers

[jsoncontentimporterpro nameoftemplate="zip" httpstatuscodemustbe200=no]

2. JCI template:

  • url:{% if %}{{}}{% else %}US{% endif %}/{% if %}{{}}{% else %}80636{% endif %}
  • urlparam4twig: zip#co
  • twig-template:
{% if %}{% set coun = %}{% else %}{% set coun = "DE" %}{% endif %}
<form action=/pro-api-zippopotamus-shortcode-parameter-httpstatuscodemustbe200/>
<select name="co" id=jciinput>
<option value="DE" {% if coun =="DE" %}selected{% endif %}>Germany</option>
<option value="US" {% if coun =="US" %}selected{% endif %}>United States</option>
<input type=text name=zip placeholder="Insert Zipcode" value="{% if %}{{}}{% else %}80636{% endif %}">
<input type=submit id=jciinput value="Search Zipcode for City">
{% if places %}
<ol>{% for p in places %}<li>
<a href="{{p.latitude}},{{p.longitude}}" target="_blank">{{ attribute(p, 'place name') }} ({{ attribute(p, 'state abbreviation') }})</a>
</li>{% endfor %}</ol>
{% else %}
{% if %}
no City to this Zipcode {{}} found
{% endif %}
{% endif %}
#jciinput {
    border-radius: 5px;
    width: 320px;
    background: #eee;
 color: black;
Examples: <a href="/pro-api-zippopotamus-shortcode-parameter-httpstatuscodemustbe200/?co=US&zip=77004">Houston, US, TX</a> | 
<a href="/pro-api-zippopotamus-shortcode-parameter-httpstatuscodemustbe200/?co=DE&zip=80636">Munich, DE, Germany</a>

PRO: param1 and param2 in the Shortcode

There is a special way to use the same JCI-Shortcode with small variations. E .g. having almost the same JCI-Shortcode on two pages with different languages .

In detail: Add param1… or param2=… to the JCI-Shortcode.


[jsoncontentimporterpro nameoftemplate="demoparam1param2" param1="value_param1" param2="value_param2"]

Effect: Both in the URL and the twig-template you can use the values of param1 and param2

URL in the template (no spaces or special chars in the param1 / param2 as the values are passed as is):

Used URL:


Twig-syntax for showing the complete JSON-data:<br>
{{ _context | json_encode  }}
<hr>param1: {{param1}}
<hr>param2: {{param2}}

In Action:

Twig-syntax for showing the complete JSON-data:
param1: value_param1
param2: value_param2

PRO: Upload and send Data to API

Your Challenge:
Offer a HTML-Form to your user for inserting some text and uploading a mediafile. The mediafile should be stored locally and displayed together with the text input. Also the text and mediafile should be sent to an API.

This is the way to achieve this:

Create two JCI-Templates.
JCI-Template 1:

  • templatename: uploadaddpic
  • URL: This must be a real API where you want to send the data (“dummyrequest” is not ok here)
  • method: CURL-POST
  • urlparam4twig: text1
  • twig-Template:
{{_context | json_encode }}

JCI-Template 2:

  • templatename: uploadmediafile
  • URL: URL to an API which gives all data you sent via this form. If not needed use “dummyrequest”.
  • method: CURL-POST
  • twig-template:
    get_data_of_uploaded_file: This JCI-twig-function returns $_FILES, a ‘superglobal’ PHP-variable where the HTTP File Upload variables are stored.
{% if urlparam.text1 %}
input text: {{urlparam.text1}}<br>
{% set picdata = get_data_of_uploaded_file('yourmediafile') %}
data of uploaded file: {{picdata | json_encode}}<hr>
{% set maxsizekb= 2*1024*1024 %}
{% if picdata.error==0 and picdata.size<maxsizekb %}
upload file is ok for saving in wp-medialib<br>
{% set jciaddkond='{"answer":"hello","urlparam":{"zip":"","co":"","text1":""},"apiresponseinfo":[]}' %}
shortcode for saving file: {{jciaddkond}}<hr>
{% set execsh = jciaddkond | doshortcode %}
shortcode-execution result: {{execsh | dump }}<br>
{% set execshArr = execsh | json_decode %}
{% set uploadedImgInWPLib = execshArr.apiresponseinfo.upload.attachment_url %}
<hr>{{urlparam.text1}}<br><img src="{{uploadedImgInWPLib }}">
{% else %}
mediafile not stored:<br>
picdata.error: {{picdata.error}}<br>
maxsize:  {{(maxsizekb/1024)| round(2)}} kB<br>
Bildgröße: {{(kondpicdata.size/1024)| round(2)}} kB<br>
{% endif %}
{% endif %}
<form action=/upload/ enctype="multipart/form-data" method=POST>
<input type=text name=text1 placeholder="Your example text">
<input type="file" name="yourmediafile">
<input type=submit>
  • urlparam4twig:

Use the JCI-Templates:

Place the following sortcode on the Page /upload/ (see <from action=…>” at twig-template JCI-Template 2, change this if needed)

[jsoncontentimporterpro nameoftemplate="uploadmediafile" orderofshortcodeeval=10] 

In Action, to avoid unwanted uploads this page is password protected:

Ok, if you need a nice free plugin out of the box: Check

Search JCI-Websites

Fatal error: Uncaught Error: Call to undefined function twig_call_macro() in /www/htdocs/w0135691/ : eval()'d code:88 Stack trace: #0 /www/htdocs/w0135691/ __TwigTemplate_7b59c5b79ecf095c010fa281378acf2239afbd8fb32b2009ef3e2cdf519ea4e0->doDisplay(Array, Array) #1 /www/htdocs/w0135691/ JCITwig\Template->displayWithErrorHandling(Array, Array) #2 /www/htdocs/w0135691/ JCITwig\Template->display(Array) #3 /www/htdocs/w0135691/ in /www/htdocs/w0135691/ : eval()'d code on line 88