Challenge: Display the data from https://api.json-content-importer.com/extra/json/date.php
Solution 1: Display direct with the APIdata and the “Auto Refresh API Ajax” Plugin
- Install the Plugin “Auto Refresh API Ajax”
- Create a HTML-Div like
<div id="time">load data</div> - Go to the “Auto Refresh AA” menu and create a slot:
- JSON URL: https://api.json-content-importer.com/extra/json/date.php
- Value to display: time
- Refresh interval: “Every second”
- Output element:
div[id="time"]
Way 1:
load time data
Solution 2: Create a JSON to have more text and data from the API
Use the JSON Content Importer PRO Template Manager and create a Template “jsonoutofjson” with:
URL: https://api.json-content-importer.com/extra/json/date.php
twig-code:
{"outdata": "Timestamp: {{time}}<br>Otherdate: {{otherdate}}"}
In Action:
{“outdata”: “Timestamp: 1783235176, Otherdate: Sun, 05 Jul 26 09:06:16 +0200”}Use this Shortcode on a published page like https://api.json-content-importer.com/jsonoutofjson/
JSON-Feed is called by “?show=oc”: https://api.json-content-importer.com/jsonoutofjson/?show=oc
Go to the “Auto Refresh AA” menu and create a slot:
- JSON URL: https://api.json-content-importer.com/extra/json/date.php
- Value to display: outdata
- Refresh interval: “Every second”
- Output element:
div[id="outdata"]
Example in Action, Way 2 (there might be a 1 minute cache active on this server):
load outdata data