a php sample made to Namecheap sandobox for testing
<?php
$apiUser = 'your_api_user';
$apiKey = 'your_api_key';
$userName = 'your_username';
$clientIp = 'your_server_ip';
$command = 'namecheap.domains.getList'; // example API command
$page = 2; // specify the page number you want
$url = 'https://api.sandbox.namecheap.com/xml.response?' . http_build_query([
'ApiUser' => $apiUser,
'ApiKey' => $apiKey,
'UserName' => $userName,
'ClientIp' => $clientIp,
'Command' => $command,
'Page' => $page,
'PageSize' => 10, // optional, how many results per page
]);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if(curl_errno($ch)) {
echo 'Curl error: ' . curl_error($ch);
} else {
echo "Response:\n";
echo htmlspecialchars($response);
}
curl_close($ch);
// etc.