Get JSON data from external website and parse it to show in HTML

Exactly. And you don’t want to JSON decode the result, neither :wink:

1 Like

I didn’t know about the request() method. I will going to use it too.
What I use till know is:

return function($site, $pages, $page) {
	
	
	$lang_code = $site->language()->code();
	$data_ai = null;
	$cacheFile = kirby()->roots()->cache().DS.md5('air').'_'. $lang_code .'.json';
	if(!f::exists($cacheFile) ||
	  ( f::exists($cacheFile) && (time() - f::modified($cacheFile) > c::get('cache.refresh', 3600)) )  // seconds
	) {
		
		$url= "http://api.openweathermap.org/data/2.5/weather?id=7285241&units=imperial&APPID=my ID";
		$url_ai = $url . '&lang=' . $lang_code;
			
			$data= file_get_contents($url_ai);
			$data_ai = json_decode($data);
			f::write($cacheFile, $data);
	} else {
	    $data_ai = json_decode(f::read($cacheFile));
	}
	
	
	
  return compact('data_ai');

to also cache the result because of the limited request per minute

ok so i have a wordpress site and a json feed from a different site i would like to show.
https://www.malliard.com/mediainfo.json

but this all has me lost… thanks in advance.

you can use curl request.you can also decode json onlinejson decode online