Here’s what I used within a custom plugin. It’s the remote
class from the Kirby Toolkit (which also uses cURL
btw.).
class myClass {
public static function getJsonData() {
$tree = [];
$url = 'http://api.domain.com';
$request = remote::request($url);
if (!empty($request->content)) {
$tree = json_decode($request->content);
}
return $tree;
}
And then …
<?php $tree = myClass::getJsonData() ?>