TransWar File Browser

Path: C:\

<?php
	define('API_KEY', '75594207-b5d7-43bf-a7c2-571b3030308d');  
	class RequestCTe {
		function getResponse($x) {
			echo 'get'.$x.'<br>';

			// Em TrĂ¢nsito e Entregue	
			$url = "https://transwar.lannister.emitir.me/ctes/search?person_group_id=4&status=2,3&page=".$x;  

			// Cadastrado, Emitido e Cancelado
			//$url = "https://transwar.lannister.emitir.me/ctes/search?person_group_id=4&status=0,1,5&page=1";  
			
			echo $url.'<br>';
			$curl = curl_init($url);
			curl_setopt($curl, CURLOPT_URL, $url);
			curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
			$headers = array(
			   "accept: application/json",
			   "x-api-key: ".API_KEY,
			);
			curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
			curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
			curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
			curl_setopt($curl, CURLOPT_HEADER, 1);
			curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
			curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
			$resp = curl_exec($curl);
			curl_close($curl);
			$out = preg_split('/(\r?\n){2}/', $resp, 2);
			$headers = $out[0];
			$body[1] = $out[1];
			echo '<pre>';
			echo $headers.'<br>';
			$headersArray = preg_split('/\r?\n/', $headers);
			$headersArray = array_map(function($h) {
			  return preg_split('/:\s{1,}/', $h, 2);
			}, $headersArray);
			$tmp = [];
			foreach($headersArray as $h) {
		    $tmp[strtolower($h[0])] = isset($h[1]) ? $h[1] : $h[0];
			}
			$headersArray = $tmp; $tmp = null;
			print_r($headersArray);
			$body[0]=$headersArray['x-ratelimit-remaining'];
		  return $body;
		}
	}
?>