PHP - Whmcs Api Help
I am using WHMCS API and It gives me an array for the first name, last name, etc for the client information
Here is the code I have so far
checkLogin.php
<?php session_start(); echo "ID: " . $_SESSION['clientID']; $postfields = array(); $postfields["action"] = "getclientsdetails"; $postfields["clientid"] = $_SESSION['clientID']; $postfields["stats"] = true; $postfields["responsetype"] = "xml"; echo "<br>"; include('XMLAPI.php'); ?>XMLAPI.php <?php /* *** WHMCS XML API Sample Code *** */ $url = "http://inzernettechnologies.com/billing/includes/api.php"; # URL to WHMCS API file $username = "user"; # Admin username goes here $password = "pass"; # Admin password goes here $postfields["username"] = $username; $postfields["password"] = md5($password); $query_string = ""; foreach ($postfields AS $k=>$v) $query_string .= "$k=".urlencode($v)."&"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); $xml = curl_exec($ch); if (curl_error($ch) || !$xml) $xml = '<whmcsapi><result>error</result>'. '<message>Connection Error</message><curlerror>'. curl_errno($ch).' - '.curl_error($ch).'</curlerror></whmcsapi>'; curl_close($ch); $arr = whmcsapi_xml_parser($xml); # Parse XML print_r($arr); # Output XML Response as Array /* Debug Output - Uncomment if needed to troubleshoot problems echo "<textarea rows=50 cols=100>Request: ".print_r($postfields,true); echo "\nResponse: ".htmlentities($xml)."\n\nArray: ".print_r($arr,true); echo "</textarea>"; */ function whmcsapi_xml_parser($rawxml) { $xml_parser = xml_parser_create(); xml_parse_into_struct($xml_parser, $rawxml, $vals, $index); xml_parser_free($xml_parser); $params = array(); $level = array(); $alreadyused = array(); $x=0; foreach ($vals as $xml_elem) { if ($xml_elem['type'] == 'open') { if (in_array($xml_elem['tag'],$alreadyused)) { $x++; $xml_elem['tag'] = $xml_elem['tag'].$x; } $level[$xml_elem['level']] = $xml_elem['tag']; $alreadyused[] = $xml_elem['tag']; } if ($xml_elem['type'] == 'complete') { $start_level = 1; $php_stmt = '$params'; while($start_level < $xml_elem['level']) { $php_stmt .= '[$level['.$start_level.']]'; $start_level++; } $php_stmt .= '[$xml_elem[\'tag\']] = $xml_elem[\'value\'];'; @eval($php_stmt); } } return($params); } ?>It outputs: ID: 1 Array ( [WHMCSAPI] => Array ( [ACTION] => getclientsdetails [RESULT] => success [CLIENT] => Array ( [USERID] => 1 [ID] => 1 [FIRSTNAME] => Cody [LASTNAME] => Robinson [FULLNAME] => Cody Robinson [COMPANYNAME] => InZernet Technologies [EMAIL] => cody-admin@inzernettechnologies.com [ADDRESS1] => Address [ADDRESS2] => [CITY] => 11 [FULLSTATE] => Michigan [STATE] => Michigan [POSTCODE] => 11111 [COUNTRYCODE] => US [COUNTRY] => US [STATECODE] => MI [COUNTRYNAME] => United States [PHONECC] => 1 [PHONENUMBER] => 1111111111 [PHONENUMBERFORMATTED] => 11111111 [BILLINGCID] => 0 [NOTES] => [PASSWORD] => PASSWORD [TWOFAENABLED] => [CURRENCY] => 1 [DEFAULTGATEWAY] => [CCTYPE] => [CCLASTFOUR] => [SECURITYQID] => 29 [SECURITYQANS] => Rogers [GROUPID] => 0 [STATUS] => Active [CREDIT] => 0.00 [TAXEXEMPT] => [LATEFEEOVERIDE] => [OVERIDEDUENOTICES] => [SEPARATEINVOICES] => [DISABLEAUTOCC] => [EMAILOPTOUT] => 0 [OVERRIDEAUTOCLOSE] => 0 [LANGUAGE] => [LASTLOGIN] => Date: 07/10/2014 17:43 IP Address: xx.xx.xx.xx.xx Host: xx.xx.xx.xx.xx.xx.xx [CUSTOMFIELDS1] => Other [CUSTOMFIELDS] => Array ( [ID] => 1 [VALUE] => Other ) [CURRENCY_CODE] => USD ) [STATS] => Array ( [NUMDUEINVOICES] => 0 [DUEINVOICESBALANCE] => $0.00 USD [INCOME] => $0.00 USD [INCREDIT] => [CREDITBALANCE] => $0.00 USD [NUMOVERDUEINVOICES] => 0 [OVERDUEINVOICESBALANCE] => $0.00 USD [NUMPAIDINVOICES] => 0 [PAIDINVOICESAMOUNT] => $0.00 USD [NUMUNPAIDINVOICES] => 0 [UNPAIDINVOICESAMOUNT] => $0.00 USD [NUMCANCELLEDINVOICES] => 0 [CANCELLEDINVOICESAMOUNT] => $0.00 USD [NUMREFUNDEDINVOICES] => 0 [REFUNDEDINVOICESAMOUNT] => $0.00 USD [NUMCOLLECTIONSINVOICES] => 0 [COLLECTIONSINVOICESAMOUNT] => $0.00 USD [PRODUCTSNUMACTIVEHOSTING] => 0 [PRODUCTSNUMHOSTING] => 0 [PRODUCTSNUMACTIVERESELLER] => 0 [PRODUCTSNUMRESELLER] => 0 [PRODUCTSNUMACTIVESERVERS] => 0 [PRODUCTSNUMSERVERS] => 0 [PRODUCTSNUMACTIVEOTHER] => 0 [PRODUCTSNUMOTHER] => 0 [PRODUCTSNUMACTIVE] => 0 [PRODUCTSNUMTOTAL] => 0 [NUMACTIVEDOMAINS] => 0 [NUMDOMAINS] => 0 [NUMACCEPTEDQUOTES] => 0 [NUMQUOTES] => 0 [NUMTICKETS] => 0 [NUMACTIVETICKETS] => 0 [NUMAFFILIATESIGNUPS] => 0 ) ) )How would I get that information into a variable I tried $params[1]; and that didn't work I tried to remove the return($params); and use it in CheckLogin.php and did echo $params; but it didn't work Any help appreciated!!!!! Similar TutorialsHi guys! I am working to create a new front end for WHMCS using the backend. Here is what I have so far:
http://inzernettechn...s.com/login.php
http://inzernettechn...om/register.php
http://inzernettechn.../clientarea.php
http://inzernettechn...setPassword.php
e-mail: cody-admin@inzernettechnologies.com
password: cmr432we
(To login to the login and to get to the client area, I know it isn't much but this is what I got done in a couple hours)
I am wondering if someone would like to help with this project with me
I was planning on selling this, so you could get some of the money from sales if you want. If you are interested, please let me know! Thanks!
Hi All, Not sure if you could maybe help with basic PHP cURL coding... I have a module to get products from another site but I keep on getting the error code below: Quote
> ArgumentCountError: Too few arguments to function curlCall(), 1 passed in /clientzone/modules/products.php on line 33 and at least 2 expected in /clientzone/includes/functions.php:0 The PHP code for the error above is: function bright_getAllProducts() { $productRequest = curlCall('http://url'); return $productRequest; } Any idea why the above error is given and how I can resolve it? Edited September 9, 2020 by Brendonm96wrong format |