    public function provarentri() {

        $certp12=Yii::app()->basePath . '/modelli/01621840188.p12';

        // Configurazione
        $config = (object) [
            "p12" => $certp12, // nome file .p12
            "password" => "09o(i6(D", // Password del file .p12
            "aud" => "rentrigov.demo.api", // Per produzione rentrigov.api
            "iss" => "01621840188", // Indicare l'identificativo dell'operatore presente nel subject del certificato (partita iva)
            "baseApi" => "https://demoapi.rentri.gov.it", // Per produzione https://api.rentri.gov.it
        ];

        $regId = "RXO5K8C8C00"; // Indicare l'identificativo del registro
        $blocco = "JGDPR"; // indetificativo blocco virtuale


        if (false) {

            // Content
            $content =  "[{\"riferimenti\": { \"numero_registrazione\": { \"anno\": 2024, \"progressivo\": 1 } }}]"; // Json data (oggetto non valido, verrà ritornato status code 400)	
            $contentType = "application/json; charset=utf-8";

            // Generazione token JWT
            $authJwt = $this->create_jwt($config);
            $intJwt = $this->create_jwt($config, $content, $contentType);

            // Chiamata API
            $res = $this->call_api(
                "POST",
                $config->baseApi . "/dati-registri/v1.0/operatore/.$regId./movimenti",
                [
                    "Authorization: Bearer " . $authJwt->jwt,
                    "Digest: " . $intJwt->digest,
                    "Agid-JWT-Signature: " . $intJwt->jwt,
                    "Content-Type: " . $contentType,
                ],
                $content,
                true,
            );

            print_r($res);
        }


        if (false) {
            // -- recupero classi ADR
            echo '<br>Classi ADR<br>';
            // Content
            $content =  ""; // Json data (oggetto non valido, verrà ritornato status code 400)	
            $contentType = "application/json; charset=utf-8";

            // Generazione token JWT
            $authJwt = $this->create_jwt($config);
            $intJwt = $this->create_jwt($config, $content, $contentType);
            
            // Chiamata API
            $res = $this->call_api(
                "GET",
                $config->baseApi . "/codifiche/v1.0/lookup/adr-classi",
                [
                    "Authorization: Bearer " . $authJwt->jwt,
                    //"Digest: " . $intJwt->digest,
                    //"Agid-JWT-Signature: " . $intJwt->jwt,
                    "Content-Type: " . $contentType,
                ],
                $content,
                false,
            );

            print_r($res);
        }


        if (false) {

            // --- vidimazione virtuale FIR
            echo '<br>Vidimazione FIR<br>';


            // Content
            $content =  ""; // Json data 	
            $contentType = "application/json; charset=utf-8";

            // Generazione token JWT
            $authJwt = $this->create_jwt($config);
            $intJwt = $this->create_jwt($config, $content, $contentType);

            // Chiamata API
            $res = $this->call_api(
                "POST",
                $config->baseApi . "/vidimazione-formulari/v1.0/".$blocco,
                [
                    "Accept: application/json, application/problem+json",
                    "Authorization: Bearer " . $authJwt->jwt,
                    //"Digest: " . $intJwt->digest,
                    //"Agid-JWT-Signature: " . $intJwt->jwt,
                    "Content-Type: " . $contentType,
                ],
                $content,
                false,
            );

            echo ($res);

        }


        if (false) {

            // --- controllo stato vidimazione FIR
            echo '<br>controllo stato Vidimazione FIR<br>';

            $id_transazione="30cc51da-bba7-47ff-b42a-3514556afc20";

            // Content
            $content =  ""; // Json data 	
            $contentType = "application/json; charset=utf-8";

            // Generazione token JWT
            $authJwt = $this->create_jwt($config);
            $intJwt = $this->create_jwt($config, $content, $contentType);

            // Chiamata API
            $res = $this->call_api(
                "GET",
                $config->baseApi . "/vidimazione-formulari/v1.0/".$id_transazione."/status",
                [
                    "Accept: application/json, application/problem+json",
                    "Authorization: Bearer " . $authJwt->jwt,
                    //"Digest: " . $intJwt->digest,
                    //"Agid-JWT-Signature: " . $intJwt->jwt,
                    //"Content-Type: " . $contentType,
                ],
                $content,
                true,
            );

            echo ($res);

        }


        if (false) {

            // --- esito vidimazione FIR
            echo '<br>Esito Vidimazione FIR<br>';

            $id_transazione="30cc51da-bba7-47ff-b42a-3514556afc20";

            // Content
            $content =  ""; // Json data 	
            $contentType = "application/json; charset=utf-8";

            // Generazione token JWT
            $authJwt = $this->create_jwt($config);
            $intJwt = $this->create_jwt($config, $content, $contentType);

            // Chiamata API
            $res = $this->call_api(
                "GET",
                $config->baseApi . "/vidimazione-formulari/v1.0/".$id_transazione."/result",
                [
                    "Accept: application/json, application/problem+json",
                    "Authorization: Bearer " . $authJwt->jwt,
                    //"Digest: " . $intJwt->digest,
                    //"Agid-JWT-Signature: " . $intJwt->jwt,
                    //"Content-Type: " . $contentType,
                ],
                $content,
                false,
            );

            echo ($res);

            $data = CJSON::decode($res, true);
            echo '<hr><br>Progressivo ' . $data['esito']['progressivo'];
            echo '<br>Seriale ' . $data['esito']['seriale'];
            // echo '<br>qrKey ' . $data['qrKey'];
            // echo '<br>cciaaNome ' . $data['cciaaNome'];
            // echo '<br>Data richiesta ' . $data['dataRichiesta'];
        }


        if (true) {

            // --- esito vidimazione FIR
            echo '<br>Recuper pdf FIR<br>';

            $progressivo="11";

            // Content
            $content =  ""; // Json data 	
            $contentType = "application/json; charset=utf-8";

            // Generazione token JWT
            $authJwt = $this->create_jwt($config);
            $intJwt = $this->create_jwt($config, $content, $contentType);

            // Chiamata API
            $res = $this->call_api(
                "GET",
                $config->baseApi . "/vidimazione-formulari/v1.0/".$blocco."/".$progressivo."/pdf",
                [
                    "Accept: application/json, application/problem+json",
                    "Authorization: Bearer " . $authJwt->jwt,
                    //"Digest: " . $intJwt->digest,
                    //"Agid-JWT-Signature: " . $intJwt->jwt,
                    //"Content-Type: " . $contentType,
                ],
                $content,
                false,
            );

            echo ($res);

            $data = CJSON::decode($res, true);
            // echo '<hr><br>Progressivo ' . $data['esito']['progressivo'];
            // echo '<br>Seriale ' . $data['esito']['seriale'];
            $nomefile=Yii::app()->basePath . '/pdf/'.$data['nome_file'];
            $pdf_formulario=base64_decode($data['content']);
            $fp = fopen($nomefile, "a");    // or exit("Impossibile aprire il file!");
            fwrite($fp, $pdf_formulario);
            fclose($fp); 
            echo '<br>File Salvato';

        }







    }

