terungwa Posted December 2, 2015 Share Posted December 2, 2015 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. 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted December 2, 2015 Share Posted December 2, 2015 You are using your API function inside an action hook so there's really no need to use external API. Simply use internal API: $command = "getclientsdetails"; $adminuser = "admin"; $values["clientid"] = "1"; $values["stats"] = true; $values["responsetype"] = "xml"; $results = localAPI($command,$values,$adminuser); Also notice that in your script you were using this: $postfields["clientid"] = "{$userid}"; "{$userid}" makes no sense. Responsetype parameter (xml) was missing. Lastly you did not specify username and the MD5 password to connect to WHMCS. 0 Quote Link to comment Share on other sites More sharing options...
terungwa Posted December 3, 2015 Author Share Posted December 3, 2015 resolved. thanks 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.