[ [ "rfid" => "000001004968", "location" => "01393A3173657005", "volt" => "0" ] ] ]; //{"data":[{"rfid":"000001004968","location":"01393A3173657005","volt":"0"}]} // 1. 将数据转换为 JSON 格式并进行 Base64 编码 $json_data = json_encode($data); var_dump($json_data); $base64_data = base64_encode($json_data); // 2. 设置 POST 请求数据 $post_data = [ 'data' => $base64_data ]; $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => $api_url, 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 =>$base64_data, CURLOPT_HTTPHEADER => array( 'Content-Type: text/plain' ), )); // 3. 接口返回的数据 $response = curl_exec($curl); curl_close($curl); var_dump($response); // 4. AES 解密函数 function aes_decrypt($data, $key) { $decrypted_data = openssl_decrypt(base64_decode($data), 'AES-128-ECB', $key, OPENSSL_RAW_DATA); return $decrypted_data; } // 5. 返回数据处理 AES 解密 // 解密密码 $password = 'njmind.comnjsjly'; $decrypted_response = aes_decrypt($response, $password); $base64_decrypted_data = base64_decode($decrypted_response); $final_response = json_decode($base64_decrypted_data, true); // 6. 输出解密后的结果 var_dump($final_response);