$url, CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => $method, CURLOPT_HTTPHEADER => $headers ?: [], ]; if ($data) { $opts[CURLOPT_POSTFIELDS] = $data; } curl_setopt_array($curl, $opts); $response = curl_exec($curl); curl_close($curl); return $response; } }