silkhost Posted January 1, 2008 Share Posted January 1, 2008 Hello, How do I access the returned variables when making an API call. I have tried many different ways to no avail. I am editting the supportticketslist.tpl. Here is what I have so far with all the fields changed for my site. The call is supposed to return the users data which I am trying to retrieve. For example, the clients email, companyname. Any help would be great. $url = "http://www.mydomainlocation.com/whmcs/includes/api.php"; $username = "Adminuser"; # Admin username goes here $password = "password"; # Admin password goes here $postfields["username"] = $username; $postfields["password"] = md5($password); $postfields["action"] = "getclientsdata"; $postfields["email"] = "demo@whmcs.com"; 0 Quote Link to comment Share on other sites More sharing options...
weyandch Posted January 2, 2008 Share Posted January 2, 2008 Heya silk, I'm still reading in the API, ran no productive tests yet.. but accoring to their example in the manual you're missing this calls to curl: $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 10); 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]; } The $postfields-Array contains the APIcall, the return values will be saved to the $data Variable 0 Quote Link to comment Share on other sites More sharing options...
Nick Posted January 2, 2008 Share Posted January 2, 2008 Seeing as you're adding code to WHMCS you should simply be querying the database, rather than using the API, which opens a second, unnecessary, connection. Set either $client_email to the email address of the client, or $client_id to the client's ID number before this code: $query = mysql_query("SELECT * FROM `tblclients` WHERE ((`email` = '" . mysql_real_escape_string($client_email) . "') || (`id` = '" . mysql_real_escape_string($client_id) . "'));"); if(mysql_num_rows($query) != 1) { echo "Error!"; } else { $data = mysql_fetch_assoc($query); echo $data['companyname']; } $data is now an array containing all the customer's details. 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.