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 you need a Shortcode and a JCI-Template.


1. The Shortcode:

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. THE HILL WE CLIMB
The poem read on President Joe Biden's Inauguration Day, by the youngest poet to write and perform an inaugural poem.


2. THE FOUR WINDS
As dust storms roll during the Great Depression, Elsa must choose between saving the family and farm or heading West.

3. THE MIDNIGHT LIBRARY
Nora Seed finds a library beyond the edge of the universe that contains books with multiple possibilities of the lives one could have lived.

4. GOOD COMPANY
The foundation of a marriage between actors is shaken when they reunite with an old friend who is now a TV star.

5. THE RED BOOK
The second book in the Black Book thriller series. Chicago detective Billy Harney investigates his own past.

6. FIRST PERSON SINGULAR
A collection of eight short stories on love, childhood and memory.

7. NORTHERN SPY
The sister of a BBC producer may have joined the Irish Republican Army.

8. THE INVISIBLE LIFE OF ADDIE LARUE
A Faustian bargain comes with a curse that affects the adventure Addie LaRue has across centuries.

9. WIN
Windsor Horne Lockwood III might rectify cold cases connected to his family that have eluded the F.B.I. for decades.

10. KLARA AND THE SUN
An “Artificial Friend” named Klara is purchased to serve as a companion to an ailing 14-year-old girl.

11. YOU LOVE ME
The third book in the You series. Joe becomes interested in a librarian who appears to be too busy for him.

12. LIFE AFTER DEATH
In a sequel to “The Coldest Winter Ever,” Winter Santiaga emerges after time served and seeks revenge.

13. THE VANISHING HALF
The lives of twin sisters who run away from a Southern Black community at age 16 diverge as one returns and the other takes on a different racial identity but their fates intertwine.

14. ETERNAL
Three people involved in a love triangle find everything they hold dear is tested as Mussolini’s power grows and laws change in Rome.

15. THE LOST APOTHECARY
An aspiring historian in London finds a clue that might put to rest unsolved apothecary murders from 200 years ago.

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:

  1. 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].

  2. 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 /]
  3. 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.

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

  5. 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.)”.

  6. 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: 2021-04-15
Time: 22:42
Water Level: 2.50

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”