ccdave Posted August 26, 2014 Share Posted August 26, 2014 Can anyone help with this please? I just get a response: The following error occured: With no error. I have replaced the sensitive parts for obvious reasons. <?php // error_reporting(E_ALL); // ini_set('display_errors', 1); $url = "http://mywhmcsurl/includes/api.php"; # URL to WHMCS API file $username = "myadminuser"; # Admin username goes here $password = "myadminpassword"; # Admin password goes here $db = mysqli_connect("localhost", "dbname", "dbpass", "dbtable"); $strSQL = "select * from tbl_contract"; $query = mysqli_query($db, $strSQL); while($row = mysqli_fetch_array($query)) { $postfields["username"] = $username; $postfields["password"] = md5($password); $postfields["action"] = "createinvoice"; $postfields["userid"] = $row["bcid"]; $postfields["date"] = "20110901"; $postfields["duedate"] = "20110901"; $postfields["paymentmethod"] = "banktransfer"; $postfields["sendinvoice"] = false; $postfields["itemdescription1"] = $row["contract_type"]; $postfields["itemamount1"] = $row["amount"]; $postfields["itemtaxed1"] = 1; $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); $data = explode(";",$data); foreach ($data AS $temp) { $temp = explode("=",$temp); $results[$temp[0]] = $temp[1]; } if ($results["result"]=="success") { # Result was OK! } else { # An error occured echo "The following error occured: ".$results["message"]; } } // CLOSE CONNECTION mysqli_close($db); ?> 0 Quote Link to comment Share on other sites More sharing options...
ccdave Posted September 9, 2014 Author Share Posted September 9, 2014 anyone? Don't seem to get many replies in these forums... 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted September 10, 2014 Share Posted September 10, 2014 maybe first you need to check what result you actually receiving for your request, change the following lines: $data = curl_exec($ch); curl_close($ch); to $data = curl_exec($ch); curl_close($ch); echo $data; print_r($data); // if the data is returned as an array, just try both output commands now you can see what result format you should expect when you calling this API 0 Quote Link to comment Share on other sites More sharing options...
ccdave Posted September 10, 2014 Author Share Posted September 10, 2014 Thanks. I am retrieving items from my database OK as I have echo'd those but I will try this today. Thank you for your suggestion. 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.