null, "premiseDistrict" => null, "companyName" => null, "flrsLicenseNo" => $verify_licence ]; $keys = "YUxzZnMyM2EjQCEyNXJlZg=="; $jsonString = json_encode($sentPayload, JSON_UNESCAPED_SLASHES); $encryptedPayload = encryptRequest($jsonString, $keys); function decryptResponse($encryptedResponse, $base64Key) { $encryptedData = base64_decode($encryptedResponse); $decodedKey = base64_decode($base64Key); $decryptedData = openssl_decrypt($encryptedData, 'AES-128-ECB', $decodedKey, OPENSSL_RAW_DATA); return $decryptedData; } $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://foscos.fssai.gov.in/webgateway/commonauth_readonly/commonapi/getsearchapplicationdetails/1', 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 => '{"encryptedPayload":"'.$encryptedPayload.'"}', CURLOPT_HTTPHEADER => array( 'Accept: application/json, text/plain, */*', 'Accept-Language: en-US,en;q=0.9', 'Connection: keep-alive', 'Content-Type: application/json', 'Origin: https://foscos.fssai.gov.in', 'Sec-Fetch-Dest: empty', 'Sec-Fetch-Mode: cors', 'Sec-Fetch-Site: same-origin', 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36', 'sec-ch-ua: "Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"', 'sec-ch-ua-mobile: ?0', 'sec-ch-ua-platform: "Windows"' ), )); $response = curl_exec($curl); curl_close($curl); // echo $response; $data = json_decode($response, true); $encryptedString = $data['encryptedResponse']; $key = "YUxzZnMyM2EjQCEyNXJlZg=="; $decrypted = decryptResponse($encryptedString, $key); $cleaned = preg_replace('/[\x00-\x1F\x7F]/', '', $decrypted); $decodedData = json_decode($cleaned, true); // print_r($decodedData); $record = $decodedData['paginationListRecords'][0]; $output = [ 'status' => 'Valid', 'companyName' => $decodedData['paginationListRecords'][0]['companyname'], 'licensecategoryname' => $decodedData['paginationListRecords'][0]['licensecategoryname'], 'licenseNo' => $decodedData['paginationListRecords'][0]['licenseno'], 'kobType' => $decodedData['paginationListRecords'][0]['refid'], ]; $curl = curl_init(); $url = "https://foscos.fssai.gov.in/gateway/common/signup/getfboapplicationkobproducts/" . $record->refid; curl_setopt_array($curl, array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', )); $response2 = curl_exec($curl); curl_close($curl); $responseKob = json_decode($response2); if (isset($responseKob->encryptedResponse)) { $decryptedResponse = decryptResponse($responseKob->encryptedResponse, $key); $cleanedResponse = preg_replace('/[\x00-\x1F\x7F]/', '', $decryptedResponse); $categories = []; $decodedData = json_decode($cleanedResponse); foreach ($decodedData as $item) { $categories[] = $item->kobName; } $output['category'] = $categories; } else { echo json_encode(['error' => 'No encrypted response found.']); } echo json_encode($output);