2016-11-29 47 views
0

我操作whmcs API來搜索DOC並打印結果。只打印whmcs中的customfields API

  <?php 
/* *** WHMCS XML API Sample Code *** */ 
    $clientId = $_POST['clienteId']; 

    $url = "https://westhost.com.br/painel/includes/api.php"; # URL to.  WHMCS API file goes here 
$username = "root"; # Admin username goes here 
$password = "sadsadsadsa"; # Admin password goes here 

    $postfields = array(); 
$postfields["username"] = $username; 
$postfields["password"] = md5($password); 
$postfields["action"] = "getclientsdetailsbydoc"; 
$postfields["clientDoc"] = $clientId; 
$postfields["stats"] = false; 
$postfields["responsetype"] = "xml"; 

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>'. 
    curl_errno($ch).' - '.curl_error($ch).'</curlerror></whmcsapi>'; 
curl_close($ch); 


$arr = whmcsapi_xml_parser($xml); # Parse XML 

if(isset($_POST['Pesquisar'])) { 
echo '<pre>'; print_r($arr); echo '</pre>'; # Output XML Response as ArraY 

} 
?> 

,結果是上面的,我怎麼能告訴XML在打印ONLY SHOW [名字[姓氏]和CUSTOMFIELDS1 ................... .................................................. .............

 Array 
(
[WHMCSAPI] => Array 
    (
     [ACTION] => getclientsdetailsbydoc 
     [RESULT] => success 
     [CLIENT] => Array 
      (
       [USERID] => 3139 
       [ID] => 3139 
       [UUID] => 248d425a-04b1-452c-ab46-428fbb9c44f1 
       [FIRSTNAME] => Luiz Henrique 
       [LASTNAME] => A de Souza 
       [FULLNAME] => Luiz Henrique A de Souza 
       [COMPANYNAME] => lionconsultoria 
       [EMAIL] => [email protected] 
       [ADDRESS1] => Cabo Frio 
       [ADDRESS2] => 
       [CITY] => Cabo Frio 
       [FULLSTATE] => RJ 
       [STATE] => RJ 
       [POSTCODE] => 28970000 

        [CUSTOMFIELDS1] => 28391656764 
        [CUSTOMFIELDS] => Array 
        (

回答

0

像這樣的東西可能工作:

echo $arr['WHMCSAPI']['CLIENT']['FIRSTNAME'] 
echo $arr['WHMCSAPI']['CLIENT']['LASTNAME'] 
echo $arr['WHMCSAPI']['CLIENT']['CUSTOMFIELDS1']