$secret, 'response' => $token, ]; if ($remoteIp) { $payload['remoteip'] = $remoteIp; } $ch = curl_init('https://challenges.cloudflare.com/turnstile/v0/siteverify'); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_POSTFIELDS => http_build_query($payload), CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 10, CURLOPT_HTTPHEADER => ['Content-Type: application/x-www-form-urlencoded'], ]); $body = curl_exec($ch); curl_close($ch); if ($body === false) { return false; } $json = json_decode($body, true); return !empty($json['success']); } }