API: santannaenergyservices.com

A Job for the PRO plugin is displaying and selecting data from the santannaenergyservices.com API.

Step 1 is creating a plugin-template with this twig-template (instead of concatenating the output you might push it directly)

{% set txt = "" %}
{% for m in model %}
{% set txt = txt ~ "<br>productId: " ~ m.productId%}
{% for r in m.rateScheduleList %}
{% set txt = txt ~ "<br>rateScheduleId: " ~ r.rateScheduleId%}
{% for rsl in r.rateSegmentList if  (rsl.rateSegmentTerm matches '/18 Months/i' ) %}
{% set txt = txt ~ "<br>rateSegmentId: " ~ rsl.rateSegmentId %}
{% for rsdl in rsl.rateSegmentDetailList%}
{% set txt = txt ~ "<br>segmentDetailId: " ~ rsdl.segmentDetailId ~ ", " ~ rsdl.chargeType %}
{% endfor %}
{% endfor %}
{% endfor %}
{% set txt = txt ~ "<hr>" %}
{% endfor %}
{{txt}}

URL:

https://santannaenergyservices.com/productSearch.php?utilityCode=COMILE&stateCode=IL&customerTypeCode=R&serviceTypeCode=E&salesChannelCode=WEB&contractSourceCode=MM

Save the plugin-template and remember the number of the template.
Add this shortcode to an page:

[jsoncontentimporterpro id=NUMBER_OF_TEMPLATE]

This should show you that:


productId: 74
rateScheduleId: 306
rateSegmentId: 306
segmentDetailId: 532, Electric Charges
segmentDetailId: 533, Service Account Charge

productId: 58
rateScheduleId: 164
rateScheduleId: 165
rateScheduleId: 166
rateScheduleId: 167
rateScheduleId: 168
rateScheduleId: 169
rateScheduleId: 170

Free Plugin with JSON-example

One user asked for hints on using a JSON like this. The solution is quite simple:

Install the free JSON Content Importer Plugin and use this Shortcode:

[jsoncontentimporter url=http://api.json-content-importer.com/extra/json/blog/blockchain_2.json basenode=consumer_reviews_api]{subloop:params:-1}
params: {params.username}
{/subloop:params}<hr>
{subloop:trader:-1}
trader: {trader.company_name}
{/subloop:trader}<hr>
{subloop-array:reviews:-1}
review: {reviews.comments}<br>
{/subloop-array:reviews}[/jsoncontentimporter]

See it in action:


The Block settings for that:

How to: urlparam4twig

You can define a urlparam4twig-list like “one#two” via the shortcode “urlparam4twig ” or (preferrably) the plugin-template.

This gives you the most flexible way to put a dynamic URL together for the API-call.

Create a template with this twig-code:

this is a template: <br>
time: {{ "now"|date("m.d.Y") }}<br>
urlparam "one": {{urlparam.one}}<br>
urlparam "two": {{urlparam.two}}

URL:

http://api.json-content-importer.com/extra/json/1.json?t={{ "now"|date("mdY") }}&a={{urlparam.one}}&b={{urlparam.two}}

urlparam4twig:

one#two

Save this template and remember the no of the template, use this shortcode:

[jsoncontentimporterpro id=ID_OF_TEMPLATE]

Click here and see the change in the following paragraph. You might change the values for the parameters.
In the back the twig code in the URL is executed and the values for “one” and “two” are used.

this is a template:
time: 10.24.2020
urlparam "one":
urlparam "two":

API: raw.githubusercontent.com

Via wordpress.org the question came in on how to use raw.githubusercontent.com… (see also here) with the free plugin.

Here we go:

[jsoncontentimporter url=https://raw.githubusercontent.com/signorejambo/tank-stock/master/tank-life.json numberofdisplayeditems=-1 basenode=tank]
fish: {subloop-array:fish:-1}quantity: {fish.quantity}<br>{/subloop-array:fish}
plants: {subloop-array:plants:-1}species: {plants.species}<br>{/subloop-array:plants}
[/jsoncontentimporter]

If you use the pro plugin this is the twig-template for that:

Continue reading “API: raw.githubusercontent.com”

API: clearmls.io – Sorting, Bearer

A request asked me, how to display data from the API clearmls.io sorted. One thing here is how to get access to the data. The other how to display that data.

Authentication at docs.clearmls.io
What the API expects is described here. At the free plugin you can set the API_KEY at the plugin setup. The free plugin can’t sort the json-data, but together with the Plugin TableSorter a sortable Table is possible, see here.

Authorization: Bearer API_KEY

With the pro plugin it’s like this:
Create a new pro plugin template with the following settings.
The “curloptions” set the http-header. “sortbyjsonfield” sorts for the latitude-values. When saving the template you get a TEMPLATE_ID of this template:

template: 
{% for i in properties | sortbyjsonfield("latitude,desc,num") %}
latitude: {{i.latitude}}, postal_code: {{i.postal_code}}<br>
{% endfor %}

url:
https://api.clearmls.io/properties

method:
curlget

curloptions:
CURLOPT_HTTPHEADER=Authorization:Bearer API_KEY

Use the new TEMPLATE_ID in the shortcode on a page or post:

[jsoncontentimporterpro  id=TEMPLATE_ID]

Free Plugin: API presseportal.de

The API of presseportal.de with Demo-Page:
[jsoncontentimporter url="http://api.json-content-importer.com/extra/json/presseportalde.json"
basenode="content"] {subloop-array:story:-1}<a href={url}>{title}</a><hr>{/subloop-array:story}
[/jsoncontentimporter]
gives you:

"nd.DerTag": Akelius beginnt mit Verkauf von Eigentumswohnungen in Berlin

Frankfurter Rundschau: Pressestimme zu AfD und Kalbitz

Maas: Ein neuer US-Präsident bringt keine Kehrtwende in der Außenpolitik

Greenpeace Aktivistinnen und Aktivisten errichten steinerne Barriere für echten Meeresschutz Granitsteine sollen artenreiches Steinriff im Schutzgebiet Adlergrund bewahren

"Ob der Abbau von Krankenhausbetten klug ist?" / Serdar Yüksel (SPD) fordert Überprüfung der Krankenhausrahmenplanung in NRW (FOTO)

Tagessieg für Florian Silbereisen und "Schlager, Stars & Sterne - Die große Seeparty in Österreich" Die Show begeisterte gestern Abend 4,31 Millionen Zuschauer

PAN AMP veröffentlicht TASKFORCE CLOUD (FOTO)

Blasenentzündung heilt auch ohne Antibiotikum

Trauriger Rekord: Halb Syrien hungert / SOS-Kinderdörfer: Inflation lässt die Not massiv ansteigen (FOTO)

Der Tourismus der historischen Hauptstadt Xi'an erholt sich allmählich

Tagesspiegel exklusiv: Berliner CDU wirbt für Führungsduo Söder/Spahn

Fairer Wettbewerb - Kommentar von Dominik Bath

AfD-Bundesschiedsgericht bestätigt die Annullierung der Mitgliedschaft von Andreas Kalbitz

RTL/ntv-Trendbarometer / FORSA-AKTUELL: Parteiwerte unverändert - Söder als Kanzlerkandidat vor Habeck und Scholz - 66 Prozent der Unions-Anhänger wollen Führungs-Duo Söder/Spahn

Berliner Ärztekammer begrüßt Beschluss der Gesundheitsminister zu Corona-Tests für Reiserückkehrer

Helge Braun: "Es wird ein aufwendiges Schuljahr"

Fleischwirtschaft warnt: Preise steigen durch Werkvertrag-Verbot um bis zu 20 Prozent

Rückkehr der Fans in Fußballstadien: Bremen und NRW wollen "sehr genau" prüfen

Tui schließt neuen Hilfsantrag nicht aus

Tui-Chef will Touristengebiete in der Türkei von Reisewarnung freistellen lassen