I have reviewed the responses in relation to this question I am asking here but, none successfully addresses this issue
I am using the Get Clients Details API to retrieve some data held about a client in the WHMCS System for a given ID via a hook to be called each time a client logs into the backend.
This is my code:
function hook_obtain_client_details_on_login($params) {
$url = "http://bemastech.com/store/includes/api.php";
$userid = $params['userid'];
$postfields["action"] = "getclientsdetails";
$postfields["clientid"] = "{$userid}";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$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")
{
$_SESSION['email'] = $results["email"];
$_SESSION['phonenumber'] = $results["phonenumber"];
$_SESSION['userid'] = $results["userid"];
}
else
{
die("An error occured. Please contact support. ({$results['message']})");
}
}
add_hook("ClientLogin",1,"hook_obtain_client_details_on_login","");
But, on login, this error is thrown up from my script:
array(3) { [0]=> string(12) "result=error" [1]=> string(29) "message=Authentication Failed" [2]=> string(0) "" }
My IP Address has been allowed to connect to the WHMCS API.
I am using WHMCS Version 6.1.1
How can I resolve this problem ? Thank you in advance.