$configPath = substr(__DIR__,0,strpos(__DIR__,"/public_html"))."/config.php"; include_once($configPath); if (!empty($_SESSION["utente"]) && $_SESSION["utente"]->permission("albo.consip") && (!empty($_GET["partita_iva"]))) { $resources = array(); $resources[] = "45885a6b-69e3-4149-a707-62275314272a"; // dataset fornitori 2020 consip $resources[] = "c9db3861-dc81-4e72-a77a-4fb39a20d51b"; // dataset fornitori 2019 consip $resources[] = "9a32cc52-05c9-4a72-95e5-a79709f33cac"; // dataset fornitori 2018 consip $resources[] = "79724110-d914-4f0a-b011-0b6443028657"; // dataset fornitori 2017 consip $resources[] = "f476dccf-d60a-4301-b757-829b3e030ac6"; // dataset fornitori 2016 consip $url = "https://dati.consip.it/api/action/datastore_search?"; $found = false; $partita_iva = number_format($_GET["partita_iva"],0,"",""); foreach ($resources as $resource_id) { $ch = curl_init(); $query = http_build_query([ 'resource_id' => $resource_id, 'q' => json_encode(array('#Partita_Iva' => $partita_iva)), 'limit' => 1 ]); curl_setopt($ch, CURLOPT_URL, $url.$query); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); $result = curl_exec($ch); if(!curl_errno($ch)) { $result = json_decode($result,true); if (isset($result["result"]["records"][0])) { $result = $result["result"]["records"][0]; $found = true; break; } } curl_close($ch); } if ($found) { ?>