Jump to content

API login


Recommended Posts

This should fix you up:

 


<?php

require ('dbconnect.php');

$email = "youremail@someplace.com";

       $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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

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