PRO-Plugin: API Zippopotamus

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


Examples: Houston, US, TX | Munich, DE, Germany
This done this way:

1 .JCI-Template:

[jsoncontentimporterpro id=ID_OF_TEMPLATE httpstatuscodemustbe200=no]

2. twig-template:

  • url:
    http://api.zippopotam.us/{% if urlparam.co %}{{urlparam.co}}{% else %}US{% endif %}/{% if urlparam.zip %}{{urlparam.zip}}{% else %}80636{% endif %}
  • urlparam4twig: zip#co
  • twig-code (“/zippopotamus/” is the URL to the WordPress-Page with the Shortcode):
    {% if urlparam.co %}{% set coun = urlparam.co %}{% else %}{% set coun = "US" %}{% endif %}
    <form action=/zippopotamus/>
    <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>
    </select>
    <input type=text name=zip placeholder="Insert Zipcode" value="{% if urlparam.zip %}{{urlparam.zip}}{% else %}80636{% endif %}">
    <input type=submit id=jciinput value="Search Zipcode for City">
    </form>
    <hr>
    {% if places %}
    <strong>Found:</strong><br>
    <ol>{% for p in places %}<li>
    <a href="https://www.google.com/maps/search/{{p.latitude}},{{p.longitude}}" target="_blank">{{ attribute(p, 'place name') }} ({{ attribute(p, 'state abbreviation') }})</a>
    </li>{% endfor %}</ol>
    {% else %}
    no City to this Zipcode {{urlparam.zip}} found
    {% endif %}
    <style>
    #jciinput {
        border-radius: 5px;
        width: 320px;
        height:35px;
        background: #eee;
     color: black;
    }
    </style>
    <hr>
    Examples: <a href="/zippopotamus/?co=US&zip=77004">Houston, US, TX</a> | 
    <a href="/zippopotamus/?co=DES&zip=80636">Munich, DE, Germany</a>
    

PRO JCI Plugin and the API of openweathermap.org

The API of openweathermap.org gives Feeds like https://samples.openweathermap.org/ and inside that JSON like https://samples.openweathermap.org/data/2.5/weather?q=London&appid=…

This can be used by the PRO JSON Content Importer Plugin for searching the weather:

For that xyou need a Shortcode and a JCI-Template.


1. The Shortcode:

[jsoncontentimporterpro id=ID_OF_TEMPLATE httpstatuscodemustbe200=no]

is all you need as Shortcode on a WordPress-Page, – Post or CPT.
“httpstatuscodemustbe200=no” is required, as the API answers with an http-Error when a place can’t be found.

2. The JCI-Template:

Continue reading “PRO JCI Plugin and the API of openweathermap.org”

Free JCI Plugin: Data from playlist with basenode and without

JSON: https://cast02.siamsa.ie/public/radio_siamsa/api/live/nowplaying/radio_siamsa
Solution:
[jsoncontentimporter url=https://cast02.siamsa.ie/public/radio_siamsa/api/live/nowplaying/radio_siamsa basenode=now_playing.song] {text}<img src={art}> [/jsoncontentimporter]
or:
[jsoncontentimporter url=https://cast02.siamsa.ie/public/radio_siamsa/api/live/nowplaying/radio_siamsa] {subloop:now_playing:-1} {subloop:now_playing.song:-1} {now_playing.song.text}<img src={now_playing.song.art}> {/subloop:now_playing.song} {/subloop:now_playing} [/jsoncontentimporter]

Books: Current Bestseller

With the free JSON Content Importer Plugin you can display the New York Times Bestseller-Booklist:

Code for that:
[jsoncontentimporter url=https://api.nytimes.com/svc/books/v3/lists/current/hardcover-fiction.json?api-key=YOUR_NYT_API_BOOK_KEY basenode=results] {list_name}<br>{subloop-array:books:-1}<img src="{books.book_image}" title="{books.title}" align="left" width="40" hspace="5"> {books.rank}. <a href="{books.amazon_product_url}" target="_blank">{books.title}</a><br>{books.description}<br clear="all"> <hr>{/subloop-array:books} [/jsoncontentimporter]


In action:

Hardcover Fiction
1. AMERICAN DIRT
A bookseller flees Mexico for the United States with her son while pursued by the head of a drug cartel.


2. GOLDEN IN DEATH
The 50th book of the In Death series. Eve Dallas seeks the sender of packages that give off toxic airborne fumes.

3. CROOKED RIVER
The 19th book in the Agent Pendergast series. Human feet inside nondescript shoes wash ashore in Florida.

4. WHERE THE CRAWDADS SING
In a quiet town on the North Carolina coast in 1969, a young woman who survived alone in the marsh becomes a murder suspect.

5. THE MUSEUM OF DESIRE
The 35th book in the Alex Delaware series. Four unrelated victims are found slaughtered in a limousine.

6. SUCH A FUN AGE
Tumult ensues when Alix Chamberlain’s babysitter is mistakenly accused of kidnapping her charge.

7. THE SILENT PATIENT
Theo Faber looks into the mystery of a famous painter who stops speaking after shooting her husband.

8. LOST
The new head of an F.B.I. task force takes on a crime syndicate run by a pair of Russian nationals.

9. THE DUTCH HOUSE
A sibling relationship is impacted when the family goes from poverty to wealth and back again over the course of many decades.

10. THE GIRL WITH THE LOUDING VOICE
A 14-year-old Nigerian girl, who is sold as a wife then as a servant, resolves to speak for herself and others.

11. DEAR EDWARD
A 12-year-old boy tries to start over after becoming the sole survivor of a plane crash in which he lost his immediate family.

12. THE GUARDIANS
Cullen Post, a lawyer and Episcopal minister, antagonizes some ruthless killers when he takes on a wrongful conviction case.

13. THE GIVER OF STARS
In Depression-era Kentucky, five women refuse to be cowed by men or convention as they deliver books.

14. A LONG PETAL OF THE SEA
A young pregnant widow and an Army doctor take a ship to Chile to escape the aftermath of the Spanish Civil War.

15. WHEN YOU SEE ME
D.D. Warren and Flora Dane join the F.B.I. agent Kimberly Quincy’s taskforce.

JCI and casino.chompcasino.com

Challenge: Load https://casino.chompcasino.com/content/chomp-casino/json/2.1/manifest_multicurrency.json and display those game-items containing a defined title.

Solution: Create a new JCI-template with the following settings.
URL: https://casino.chompcasino.com/content/chomp-casino/json/2.1/manifest_multicurrency.json
urlparam4twig : t

Twig code in template:

{% set t = 'Mont' %}
{% if urlparam.t %}
{% set t = urlparam.t %}
{% endif %}
term: {{t}}<br>
{% for g in games if g.title matches '/'~t~'/i'  %}
title: {{g.title}}<br>
{% for i in g.images %}
{{i.url}}
{% endfor %}
<hr>
{% endfor %}

Create new page with this Shortcode: [jsoncontentimporterpro id=NUMBER_OF_JCI_TEMPLATE]

In Action:

Try also this: http://api.json-content-importer.com/jci-and-casino-chompcasino-com/?t=romance

term: Mont
title: Montezuma
/content/all/images/montezuma/banner.jpg /content/all/images/montezuma/tile.jpg

JCI and TablePress

The Plugin “TablePress” and the PRO version of the JSON Content Importer can work together in this way:

First: Create a new TablePress-Table with e. g. two columns and two rows. Fill the cells with some dummy text. This gives you a shortcode [table id=NUMBER_OF_TABLEPRESS_TABLE].

Second: Create a new JCI-Plugin Template with e. g. some JSON data. The Twig-Code is

name: {{_context.0.name}}
[table “NUMBER_OF_TABLEPRESS_TABLE” not found /]

Third: Create a new WordPress-Page/Post with
[jsoncontentimporterpro id=NUMBER_OF_JCI_TEMPLATE]

Preview this page: You should see some “name”-Data and a Table.

Then change the content of a Table-Cell and insert {{_context.0.name}} there.

Preview the page again: If you see the Twig-Code in the Tablecell go to the JCI-Plugin-Options, Tab Settings and select “first third-party-Shortcodes, 2nd: JSONContentImporter-Shortcode (use this for TablePress, Contact Form 7 etc.)”.

Preview again and you should see the JSON-data in the Table.

If the number of columns or rows is dynamic: Up to my knowleded TablePress has a fixed number of cols and rows. So this is not that flexible.
Maybe Table Sort is an option then.

JCI and Table Press in Action:

name: Love Breakfast
1a: {{_context.0.name}}1b
2a2b

API waterservices.usgs.gov and “Auto Refresh API Ajax”

Challenge: Display the data from https://waterservices.usgs.gov/nwis/iv/?format=json&sites=01407600&parameterCd=72279&siteStatus=active

Simply displaying data is easy – create a Plugin template with the above URL and this Twigcode (Shortcode: [jsoncontentimporterpro id=NO_OF_TEMPLATE])

Location:  {{value.timeSeries.0.sourceInfo.siteName}}<br>
Date: {{value.timeSeries.0.values.0.value.0.dateTime | date("Y-m-d",   "America/New_York") }} <br>
Time: {{value.timeSeries.0.values.0.value.0.dateTime | date("H:i",  "America/New_York") }}<br>
Water Level: {{value.timeSeries.0.values.0.value.0.value}}

In Action:

Location: Shrewsbury River at Sea Bright NJ
Date: 2020-02-18
Time: 07:00
Water Level: 1.36

Display this data with the “Auto Refresh API Ajax” Plugin- Way 1:

  • Install the Plugin
  • Create a HTML-Div like <div id=”araatest”>load data</div>
  • Go to the “Auto Refresh AA” menu and insert this:
  • URL: See above
  • What: value.timeSeries.0.values.0.value.0.value
  • Where: div[id=”araatest”]

Display this data with the “Auto Refresh API Ajax” Plugin- Way 2:

Create a new JSON-Feed by adding a new plugin-template:
URL: https://waterservices.usgs.gov/nwis/iv/?format=json&sites=01407600&parameterCd=72279&siteStatus=active

{"data": "Location:  {{value.timeSeries.0.sourceInfo.siteName}}, Date: {{value.timeSeries.0.values.0.value.0.dateTime | date("Y-m-d",   "America/New_York") }}, Time: {{value.timeSeries.0.values.0.value.0.dateTime | date("H:i",  "America/New_York") }},Water Level: {{value.timeSeries.0.values.0.value.0.value}}"}

Put [jsoncontentimporterpro id=NO_OF_TEMPLATE] on a new page. This page should be something like this:
http://api.json-content-importer.com/json-waterservices-usgs-gov/
Adding “?show=oc” removes the template and gives pure JSON:
http://api.json-content-importer.com/json-waterservices-usgs-gov/?show=oc http://api.json-content-importer.com/json-waterservices-usgs-gov/?show=oc
This JSON we use in “Auto Refresh API Ajax”

In action:

load data