didier1 Posted November 19, 2013 Share Posted November 19, 2013 Hi, I started working with API and no matter what I tried, I received authentication failed whe naccessing my PHP file that is located on a different server. At first I was receiving the message that ask me to authorize my IP. I registered the IP adress of my external PHP server. Sicne then I am receving authentication failed. API user was created and given full permission. I am not using any symbol character and here's the coding in my PHP file. please help: <?php $url = "http://www.XXXX.ca/whmcs/includes/api.php"; # URL to WHMCS API file $username = "XXXX"; # Admin username goes here $password = "XXXX"; # Admin password goes here $postfields["action"] = "getproducts"; $postfields["gid"] = "5"; $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); $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") { # Result was OK! } else { # An error occured echo "The following error occured: ".$results["message"]; } ?> 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted November 19, 2013 Share Posted November 19, 2013 You forgot to specify an access key. 0 Quote Link to comment Share on other sites More sharing options...
didier1 Posted November 19, 2013 Author Share Posted November 19, 2013 Hi Kian and thanks for the quick reply. As per my understanding, the api key is in place so you dont have to register any IP. It has nothing to do with the error message : The following error occured: Authentication Failed. However I respect your idea and I modified the configuration.php to includ: $api_access_key = "XXXX"; I noticed that in the WHMCS documentation, they are asking to modify the PHP to includ : &accesskey=xxxxx , but I was running with an error message, I believe it should more look like that : $accesskey="XXXX"; $url = "http://www.immowebexpert.ca/whmcs/includes/api.php"; # URL to WHMCS API file $username = "XXX"; # Admin username goes here $password = "XXX"; # Admin password goes here $postfields["action"] = "getproducts"; $postfields["gid"] = "5"; $accesskey="XXXX"; I am still receiving the same error message, I believe it has something to do with the apiadmin that I created.... thanks 0 Quote Link to comment Share on other sites More sharing options...
gohigher Posted November 19, 2013 Share Posted November 19, 2013 I believe you have to md5 the password... no? $url = "http://www.XXXX.ca/whmcs/includes/api.php"; # URL to WHMCS API file $username = "XXXX"; # Admin username goes here $password = md5( trim( "XXXX" ) ); # Admin password goes here 0 Quote Link to comment Share on other sites More sharing options...
didier1 Posted November 19, 2013 Author Share Posted November 19, 2013 Hi gohigher, still no luck with md5. 0 Quote Link to comment Share on other sites More sharing options...
gohigher Posted November 20, 2013 Share Posted November 20, 2013 I just realized, if that's the exact code you are using it looks like you aren't including the actual username / password in the postfields... it should be something like this: $url = "http://www.XXXX.ca/whmcs/includes/api.php"; # URL to WHMCS API file $username = "XXXX"; # Admin username goes here $password = "XXXX"; # Admin password goes here $postfields["username"] = $username; $postfields["password"] = md5( $password ); $postfields["action"] = "getproducts"; $postfields["gid"] = "5"; ... Try that and see if that helps out... 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted November 20, 2013 Share Posted November 20, 2013 I just realized, if that's the exact code you are using it looks like you aren't including the actual username / password in the postfields... it should be something like this: Eagle eye You are totally right. 0 Quote Link to comment Share on other sites More sharing options...
didier1 Posted January 5, 2014 Author Share Posted January 5, 2014 yes that is correct, ist working now ! 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.