webix Posted March 23, 2020 Share Posted March 23, 2020 Hello Folks. I am trying to do a user verification, user login and ordering using the WHMCS API. The goal is to have a custom frontend cart completely separated from WHMCS (personal reasons). Now, i have this problem: When i use the php code with my browser, my browser IP is passed to WHMCS API instead of the server IP where the php code is hosted. And using the variable $api_access_key is not working (it doesn't bypass the IP check). So... here's my php code: <?php /** * Getting started with the WHMCS API Tutorial */ // Set your WHMCS URL and API Authentication Credentials $whmcsUrl = "shop/"; $apiIdentifier = "API_IDENTIFIER_REMOVED"; $apiSecret = "API_SECRET_REMOVED"; $accesskey = "ACCESS_KEY_REMOVED"; $Email = 'testclient@hotmail.com'; $Senha = md5('testClientPassword'); // Build post values $postfields = array( 'action' => 'ValidateLogin', 'accesskey' => $accesskey, 'identifier' => $apiIdentifier, 'secret' => $apiSecret, 'email' => $Email, 'password2' => $Senha, 'responsetype' => 'json', ); // Call the API $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $whmcsUrl . 'includes/api.php'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postfields)); $response = curl_exec($ch); if (curl_error($ch)) { die('Unable to connect: ' . curl_errno($ch) . ' - ' . curl_error($ch)); } curl_close($ch); // Decode response $jsonData = json_decode($response, true); // Dump array structure for inspection var_dump($response); var_dump($jsonData); ?> I have double checked all the authentication informations and they are correct. The result of the above code is: result=error;message=Invalid IP xxx.xxx.xxx.xxx Note 1: This Invalid IP is my own IP and not the IP where the above script and whmcs are hosted. Note 2: On the WHMCS security tab, i added 127.0.0.1 (and also the server public IP address) on API IP Access Restriction. Note 3: The webserver is behind cloudflare. 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.