JSON_decoder.php


<?php
// Modify here:
$q = $_GET['q'];
if(!isset($q)) $q = 'fns';

$url = 'http://search.freenamesystem.eu/json_service/JSON.php?q=' . $q;

// Stream structure
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: it\r\n" .
"Content-Type: text/html; charset=iso-8859-1\r\n"
)
);

// Context stream
$context = stream_context_create($opts);

// Query through HTTP headers
$string = file_get_contents($url, false, $context);

//echo($string);
$json_a=json_decode($string,true);

// Array method.
foreach($json_a as $p){
echo('<b>Name</b>: ' . $p[name]);
echo('<br />');
echo('<b>Reversed name</b>: <a href="'. $p[reversedName] . '">' . $p[reversedName] .'</a>');
echo('<br />');
echo('<b>Titolo</b>: ' . $p[titolo]);
echo('<br />');
echo('<b>Descr</b>: ' . $p[descrizione]);
echo("<br /><br />");
}
?>

I commenti sono chiusi.