Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WHMCS error occured: Invalid IP ::1, when using External API

Tags:

php

whmcs

I am trying out GetClient Password on External API

<?php 
$url = "http://localhost:81/whmcs/includes/api.php"; # URL to WHMCS API file goes here
$username = "admin"; # Admin username goes here
$password = "pass"; # Admin password goes here

$postfields["username"] = $username;
$postfields["password"] = md5($password);
$postfields["action"] = "GetClientPassword";
$postfields["userid"] = "1";

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
$data = curl_exec($ch);
curl_close($ch);

$data = explode(";",$data);
foreach ($data AS $temp) {
    $temp = explode("=",$temp);
    $results[$temp[0]] = $temp[1];
}

if ($results["result"]=="success") {
  echo "Success<br />
<br />
";
# Result was OK!
} else {
# An error occured
echo "The following error occured: ".$results["message"];
}
?>

Getting an error

result=error;message=Invalid IP ...

I already added the IP in General Setting -> Security Tab.

Note: I am trying this on localhost (xampp)

What am I missing here?

like image 363
Vivek Avatar asked Mar 13 '26 23:03

Vivek


1 Answers

This error means the API Access Key has not been added successfully to the configuration.php file. Please refer to step 7 above. The $api_access_key line should go before the closing ?> tag.

Source

You can also whitelist your IP by following

Setup>General>Security>API IP Access Restriction

like image 163
Xaurav Avatar answered Mar 15 '26 13:03

Xaurav



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!