Jump to content

Authentication failed on API integration


didier1

Recommended Posts

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"];

}

 

?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated