lordam Posted May 26, 2011 Share Posted May 26, 2011 Hello, please hellp. I have csv file: id_client;amount;description; id_client2;amount2;description2; id_client5;amount4;description3; I need import this date in WHMCS Credit. But when i check API i see nothing. <?php $url = "https://url/includes/api.php"; # URL to WHMCS API file $username = "admin@admin.com"; # Admin username goes here $password = "xxx"; # Admin password goes here $postfields["username"] = $username; $postfields["password"] = $password; $postfields["action"] = "addcredit"; $postfields["clientid"] = "37"; $postfields["description"] = "Adding funds via custom module"; $postfields["amount"] = "40.00"; ?> 0 Quote Link to comment Share on other sites More sharing options...
lordam Posted June 15, 2011 Author Share Posted June 15, 2011 Nobody Knows? 0 Quote Link to comment Share on other sites More sharing options...
newgenservices Posted June 15, 2011 Share Posted June 15, 2011 Your import script will need to read CSV into an array and then loop through this array, validate info and add credit to WHMCS users using WHMCS API (code you mentioned above). 0 Quote Link to comment Share on other sites More sharing options...
lordam Posted June 16, 2011 Author Share Posted June 16, 2011 About CSV code it now. I have problem with code: <?php $url = "https://url/includes/api.php"; # URL to WHMCS API file $username = "admin@admin.com"; # Admin username goes here $password = "xxx"; # Admin password goes here $postfields["username"] = $username; $postfields["password"] = $password; $postfields["action"] = "addcredit"; $postfields["clientid"] = "37"; $postfields["description"] = "Adding funds via custom module"; $postfields["amount"] = "40.00"; ?> I can not add credit using thise example code, where the error? 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted June 18, 2011 Share Posted June 18, 2011 I dont see anywhere where you are passing the $postfields variable to curl. That code you pasted basically does nothing other than assigning variables. 0 Quote Link to comment Share on other sites More sharing options...
lordam Posted July 6, 2011 Author Share Posted July 6, 2011 now i using code: <?php $url = "https://domen/includes/api.php"; # URL to WHMCS API file $username = "admin"; # Admin username goes here $password = "xxxxxx"; # Admin password goes here $postfields["username"] = $username; $postfields["password"] = md5($password); $postfields["action"] = "addcredit"; $postfields["clientid"] = "17"; $postfields["description"] = "Adding funds via custom module"; $postfields["amount"] = "40.00"; $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") { } else { # An error occured echo "The following error occured: ".$results["message"]; } ?> but not add credit. 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.