ciao!
allora, il codice è questo:
codice:
function get_json($attr) {
$baeUrl = 'http://IP_SERVER:1337/announcements';
$args = shortcode_atts(array(
'url' => $baeUrl,
), $attr);
$url = $args['url'];
if (empty($url)) {
$url = $baeUrl;
}
$data = file_get_contents($url);
$json = json_decode($data, true);
var_dump($args);
echo '<hr>';
var_dump($data);
echo '<hr>';
var_dump($json);
$html = '';
// foreach ($json as $j) {
// $html .= $j['title'] . '<br>';
// }
// var_dump($html);
return $html;
}
add_shortcode('cms-plugin', 'get_json');
e viene richiamato all'interno di un plugin di wordpress.
sulla pagina vedo questo:
codice:
array(1) { ["url"]=> string(39) "http://IP_SERVER:1337/announcements" }
---------------------------
bool(false)
---------------------------
NULL
ovviamente se lancio un curl su quell'indirizzo funziona.
come anche se al posto di quell'indirizzo ci metto una qualsiasi API con HTTPS funziona.