kurbot Posted December 3, 2008 Share Posted December 3, 2008 Is anyone else having trouble utalizing the Invoice Generation Api? What i have is the following <?php $whmcsurl = "http://mydomain.com/includes/api.php"; # URL to WHMCS API file $username = "myadminuser"; # Admin username goes here $password = "myadminpass"; # Admin password goes here $postfields["action"] = "createinvoice"; $postfields["userid"] = "8"; $postfields["date"] = "2008/12/03"; $postfields["duedate"] = "2008/12/30"; $postfields["paymentmethod"] = "paypal"; $postfields["sendinvoice"] = false; $postfields["itemdescription1"] = "(".date("m/d/Y").") Phone Service Performed"; $postfields["itemamount1"] = "10.00"; $postfields["itemtaxed1"] = 0; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $whmcsurl); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $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") { echo "Invoice Generated Successfully<br /><br />"; } else { # An error occured echo "The following error occured: ".$results["message"]; } ?> Now the above is pulling ffrom a PHP form created then submitting results im using the abov as a sample submition.. When viewing the form and after submitting i receive and error of : authentication failed. If anyone has any suggestions that would be helpful, im trying to generate a neat little time counter tool for hte support tickets, where when on the phone or when performing a service i can start a counter which ive already created utalizing the addon manager. It uses a product i created, with configurations set for time purchased and time left.. it updates all of it correctly, the last step was having it create an invoice if they didnt have a service plan.. To cut this short, im just having trouble with the API. Let me know. 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted December 4, 2008 Share Posted December 4, 2008 Are you perhaps forgetting these 2 variables? $postfields["username"] = $myadminuser;$postfields["password"] = md5($myadminpass); 0 Quote Link to comment Share on other sites More sharing options...
kurbot Posted December 4, 2008 Author Share Posted December 4, 2008 Yes ive tried that, still provides the same error.. The following error occured: Authentication Failed. any other thaughts? 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted December 4, 2008 Share Posted December 4, 2008 Is the admin user that your using the head admin (required) or a sales/support admin? 0 Quote Link to comment Share on other sites More sharing options...
kurbot Posted December 4, 2008 Author Share Posted December 4, 2008 The admin and pass im using is the primary administrator for accessing the administration panel of WHMCS. IT seems the api file is not cooperating with any type of scripts, i was reviewing the whmcs documentation on API, and i even tested some of there examples.. those also dont work.. If this helps.. im using the Licensing Module and that works just fine this module utalizes API also, if i remember correctly it had me swap out the includes/api.php file to one that was allowed to use licensing.. maybe there is a restriction or a bug in the "new api.php file"? Thanks for you help so far.. 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted December 4, 2008 Share Posted December 4, 2008 Is the date fields supposed to have slashes in them? 0 Quote Link to comment Share on other sites More sharing options...
kurbot Posted December 4, 2008 Author Share Posted December 4, 2008 thats what the example showed in the api documentation.. ive tried it all ways though.. 2008/m/d yyyymmdd dd/mm/yyyy etc.. I wish i could turn on a debugging mode or something however the api.php file is encrypted.. so i can not find out why persay or what line its failing on in the api.. Im looking through google too no one else seems to have this issue.. but i havent seen anyone elses examples yet.. ill see what i can figure out here.. 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted December 4, 2008 Share Posted December 4, 2008 http://wiki.whmcs.com/API:Create_Invoice 0 Quote Link to comment Share on other sites More sharing options...
kurbot Posted December 4, 2008 Author Share Posted December 4, 2008 (edited) Yea, that did not work, i was matching structure to what was in my DB already.. and all entry itself matches the SQL table structure.. I've even tried created an new administrative user, starting with FULL rights testing and working all the way down the chain to no rights.. still no avail. I do beleive the API error is related to authenticating the Admin User.. Something in the API blocking or not actually validating users. Edited December 4, 2008 by kurbot wanted to make a new note 0 Quote Link to comment Share on other sites More sharing options...
VirtualSims Posted December 9, 2008 Share Posted December 9, 2008 Has anyone figured this out? I'm having the exact same problem. I have the head admin username/password put in exactly and I'm using word for word example in the documentation and it still does not work. "The following error occured: Authentication Failed" 0 Quote Link to comment Share on other sites More sharing options...
VirtualSims Posted December 9, 2008 Share Posted December 9, 2008 Kurbot here is your problem, surprisingly I didn't notice it and no one else did. Your username and password aren't being passed along. You need to add this: $postfields["username"] = $username; $postfields["password"] = md5($password); 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted December 9, 2008 Share Posted December 9, 2008 Kurbot here is your problem, surprisingly I didn't notice it and no one else did. Your username and password aren't being passed along. You need to add this: $postfields["username"] = $username; $postfields["password"] = md5($password); Look at post #2 0 Quote Link to comment Share on other sites More sharing options...
VirtualSims Posted December 10, 2008 Share Posted December 10, 2008 (edited) Try adding www to the front of the domain. That was also suggested to me from WHMCS support. Also, are you sure that you have API turned on? By default it's turned on but double check, go to Configuration -> Administration Roles -> Full Administrator -> and make sure that API Access has a checkmark beside it. Edited December 10, 2008 by VirtualSims 0 Quote Link to comment Share on other sites More sharing options...
kurbot Posted December 11, 2008 Author Share Posted December 11, 2008 Yea All the check boxes are on.. I've also tried it both ways with www. and no www. 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted December 12, 2008 Share Posted December 12, 2008 turn on error_reporting in your script there may be an answer there for you 0 Quote Link to comment Share on other sites More sharing options...
kurbot Posted January 13, 2009 Author Share Posted January 13, 2009 I'm sorry.. im not sure where error_reporting is in WHMCS.. rather maybe i do... but never used it.. Ill turn it on if you could inform me of where its located. 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted January 14, 2009 Share Posted January 14, 2009 I'm sorry.. im not sure where error_reporting is in WHMCS.. rather maybe i do... but never used it.. Ill turn it on if you could inform me of where its located. It's not in WHMCS. http://au2.php.net/manual/en/function.error-reporting.php 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.