$action, 'input' => $text ]); $ch = curl_init($url); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_POSTFIELDS => $payload, CURLOPT_HTTPHEADER => [ 'Content-Type: application/json' ], CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 15 ]); $response = curl_exec($ch); if ($response === false) { throw new RuntimeException(curl_error($ch)); } $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); $data = json_decode($response, true); if ($status !== 200 || !isset($data['result'])) { throw new RuntimeException('API gagal memproses data'); } return $data['result']; } // Contoh Encode echo base64API('Hello World', 'encode'); // Contoh Decode // echo base64API('SGVsbG8gV29ybGQ=', 'decode'); ?>