<?php

function findLV($immatriculation) {

 if(strlen($immatriculation) < 7 ){
  return false;
 }
 $curl = curl_init();

 $im = '{"id":"0","name":"","errors":"","json":"{\\"method\\":\\"GET\\",\\"url\\":\\"https://immatriculer.com/api/info-immat?immat=AA-123-BC&departement=65&type=ctvo\\",\\"apiNode\\":\\"US\\",\\"contentType\\":\\"\\",\\"content\\":\\"\\",\\"headers\\":\\"authority: immatriculer.com\\\\r\\\\npragma: no-cache\\\\r\\\\ncache-control: no-cache\\\\r\\\\nsec-ch-ua: \\\\\\"Chromium\\\\\\";v=\\\\\\"94\\\\\\", \\\\\\"Google Chrome\\\\\\";v=\\\\\\"94\\\\\\", \\\\\\";Not A Brand\\\\\\";v=\\\\\\"99\\\\\\"\\\\r\\\\naccept: application/json, text/plain, */*\\\\r\\\\nsec-ch-ua-mobile: ?0\\\\r\\\\nuser-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.54 Safari/537.36\\\\r\\\\nsec-ch-ua-platform: \\\\\\"macOS\\\\\\"\\\\r\\\\nsec-fetch-site: same-origin\\\\r\\\\nsec-fetch-mode: cors\\\\r\\\\nsec-fetch-dest: empty\\\\r\\\\nreferer: https://immatriculer.com/formulaire\\\\r\\\\naccept-language: en-US,en;q=0.9\\\\r\\\\ncookie: _ga=GA1.2.1144723667.1621303630; sib_cuid=7b5b7ad7-3bce-41e1-9d83-f76d82dc19cd; paperless_main_prod_session=Q3C1Js5RxA86L3TFHAjt1HSSaYYTQR8o6yoVTn8R; _gcl_au=1.1.1091211061.1633032427; AeFirst5eeddbd4ecaf0d51bbf0b31c=1633032450197; _uetsid=00218bc0222a11eca566555d0acc1e15; _uetvid=00221450222a11ec822373f22e0a6256; paperless_main_prod_session=Q3C1Js5RxA86L3TFHAjt1HSSaYYTQR8o6yoVTn8R\\\\r\\\\n\\",\\"errors\\":\\"\\",\\"curlCmd\\":\\"curl --location --request GET \'https://immatriculer.com/api/info-immat?immat=AA-123-BC&departement=65&type=ctvo\' \\\\\\\\\\\\n--header \'authority: immatriculer.com\' \\\\\\\\\\\\n--header \'pragma: no-cache\' \\\\\\\\\\\\n--header \'cache-control: no-cache\' \\\\\\\\\\\\n--header \'sec-ch-ua: \\\\\\"Chromium\\\\\\";v=\\\\\\"94\\\\\\", \\\\\\"Google Chrome\\\\\\";v=\\\\\\"94\\\\\\", \\\\\\";Not A Brand\\\\\\";v=\\\\\\"99\\\\\\"\' \\\\\\\\\\\\n--header \'accept: application/json, text/plain, */*\' \\\\\\\\\\\\n--header \'sec-ch-ua-mobile: ?0\' \\\\\\\\\\\\n--header \'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.54 Safari/537.36\' \\\\\\\\\\\\n--header \'sec-ch-ua-platform: \\\\\\"macOS\\\\\\"\' \\\\\\\\\\\\n--header \'sec-fetch-site: same-origin\' \\\\\\\\\\\\n--header \'sec-fetch-mode: cors\' \\\\\\\\\\\\n--header \'sec-fetch-dest: empty\' \\\\\\\\\\\\n--header \'referer: https://immatriculer.com/formulaire\' \\\\\\\\\\\\n--header \'accept-language: en-US,en;q=0.9\' \\\\\\\\\\\\n--header \'cookie: _ga=GA1.2.1144723667.1621303630; sib_cuid=7b5b7ad7-3bce-41e1-9d83-f76d82dc19cd; paperless_main_prod_session=Q3C1Js5RxA86L3TFHAjt1HSSaYYTQR8o6yoVTn8R; _gcl_au=1.1.1091211061.1633032427; AeFirst5eeddbd4ecaf0d51bbf0b31c=1633032450197; _uetsid=00218bc0222a11eca566555d0acc1e15; _uetvid=00221450222a11ec822373f22e0a6256; paperless_main_prod_session=Q3C1Js5RxA86L3TFHAjt1HSSaYYTQR8o6yoVTn8R\'\\",\\"codeCmd\\":\\"\\",\\"auth\\":{\\"auth\\":\\"noAuth\\",\\"bearerToken\\":\\"\\",\\"basicUsername\\":\\"\\",\\"basicPassword\\":\\"\\",\\"customHeader\\":\\"\\",\\"encrypted\\":\\"\\"},\\"compare\\":false,\\"idnUrl\\":\\"https://immatriculer.com/api/info-immat?immat=AA-123-BC&departement=65&type=ctvo\\"}","deviceId":"9a2ec772-3dfd-4d2c-853c-935324084388R","sessionId":1634513672250}';

 $im = str_replace("AA-123-BC", $immatriculation, $im);


 curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://apius.reqbin.com/api/v1/requests',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => $im,
  CURLOPT_HTTPHEADER => array(
   'authority: apius.reqbin.com',
   'sec-ch-ua: "Chromium";v="94", "Google Chrome";v="94", ";Not A Brand";v="99"',
   'pragma: no-cache',
   'sec-ch-ua-mobile: ?0',
   'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36',
   'content-type: application/json',
   'accept: */*',
   'expires: 0',
   'cache-control: no-cache, no-store, must-revalidate',
   'sec-ch-ua-platform: "macOS"',
   'origin: https://reqbin.com',
   'sec-fetch-site: same-site',
   'sec-fetch-mode: cors',
   'sec-fetch-dest: empty',
   'referer: https://reqbin.com/',
   'accept-language: en-US,en;q=0.9'
  ),
 ));

 $response = curl_exec($curl);

 curl_close($curl);
 $response =  json_decode($response);
 $response = json_decode($response->Content);
 $response = $response->payload->infoimmat;
 return  $response;
}