Results 1 to 6 of 6

Thread: API login

  1. #1
    Join Date
    Nov 2008
    Posts
    2

    Smile API login

    Hello,
    I need some help. I must check email and password entered by a user in a secondary script. I tried api but fail to check. I used "getclientsdatabyemail" but the password is not md5 encrypted.
    Can help me?

  2. #2
    Join Date
    Nov 2008
    Posts
    2

    Default

    Please....i need quickly one solution

  3. #3
    Join Date
    Mar 2008
    Posts
    215

    Default

    This should fix you up:

    Code:
    <?php
    
    require ('dbconnect.php');
    
    $email = "[email protected]";
    
            $query = "SELECT username, password FROM tbladmins WHERE roleid='1' LIMIT 1";
            $result = mysql_query($query);
            while ($data = mysql_fetch_array($result))
            {
                $adminusername = $data['username'];
                $adminpassword = $data['password'];
            }
           
            $url = "https://whmcs_dir/includes/api.php";
           
            $postfields["username"] = $adminusername;
            $postfields["password"] = $adminpassword;
            $postfields["action"] = "getclientsdatabyemail";
            $postfields["email"] = $email;
            $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);
            //print_r ($data);
            //exit();
            $data = explode(";", $data);
            foreach ($data as $temp)
            {
                $temp = explode("=", $temp);
                $results[$temp[0]] = $temp[1];
            }
            if ($results["result"] == "success")
            {
                $clientid = $results["userid"];
                $firstname = $results["firstname"];
                $lastname = $results["lastname"];
                $companyname = $results["companyname"];
                $address1 = $results["address1"];
                $address2 = $results["address2"];
                $city = $results["city"];
                $state = $results["state"];
                $postcode = $results["postcode"];
                $phonenumber = $results["phonenumber"];
            }
            else
            {
                die("An error occured. Please contact support. ({$results['message']})");
            }
    
    
    echo $clientid;
    
    
    ?>

    enjoy,
    Tom
    Rapid Payment Solutions
    eProcessing Network Authorized Agent

  4. #4
    Join Date
    Jun 2009
    Posts
    83

    Default

    Hate to dig up an old thread, but just to let you know that the above won't work. It's a nice idea, but unfortunately the passwords in the database are MD5 encrypted, whereas the API needs the unencrypted password.

  5. #5
    Join Date
    Mar 2008
    Posts
    215

    Default

    Quote Originally Posted by JulesR View Post
    Hate to dig up an old thread, but just to let you know that the above won't work. It's a nice idea, but unfortunately the passwords in the database are MD5 encrypted, whereas the API needs the unencrypted password.
    I guess you haven't tested this? I use this all the time and it works fine.
    Rapid Payment Solutions
    eProcessing Network Authorized Agent

  6. #6
    Join Date
    Jun 2009
    Posts
    83

    Default

    Quote Originally Posted by tomdchi View Post
    I guess you haven't tested this? I use this all the time and it works fine.
    EDIT: Ignore me, missed the md5 part further down, sorry

Similar Threads

  1. Login API
    By robotronik in forum Feature Requests
    Replies: 3
    Last Post: 03-17-11, 06:18 AM
  2. Can't figure out login validation through API.
    By fmeos in forum Customisation & Integration Questions
    Replies: 0
    Last Post: 01-27-11, 12:04 PM
  3. Validate Login API
    By joshmarty in forum Customisation & Integration Questions
    Replies: 2
    Last Post: 12-04-10, 08:15 PM
  4. API | Login / Logout
    By Redundant in forum Feature Requests
    Replies: 5
    Last Post: 01-21-09, 09:33 PM