Jump to content

Custom PHP to verify login


webix

Recommended Posts

Hello folks!

I am developping a custom control panel for my users to manage their IP addresses (rDNS, etc...).
I want they use their email address and password from WHMCS to login on the panel.

In order to do that, i made a login form that will pass the POST data (email and password hashed in MD5) to the following function:

function validate_login($email, $password) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://XXX.XXXXXXX.XXX/includes/api.php');
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS,
        http_build_query(
            array(
                'action' => 'ValidateLogin',
                // See https://developers.whmcs.com/api/authentication
                'username' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
                'password' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXxxXX',
                'email' => $username,
                'password2' => $password,
                'responsetype' => 'json',
            )
        )
    );
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    return curl_exec($ch);
    curl_close($ch);
}

The problem is that the function returns in error with the message "Email or Password Invalid".

Anyone can help me out to find the error?

Best regards

Link to comment
Share on other sites

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