duanbi3385 2016-11-29 13:46 采纳率: 100%
浏览 32
已采纳

在whmcs API中仅打印自定义字段

i manipulate whmcs API to search for a DOC and print results.

         <?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

}
 ?>

And the Result is Above, How Can I tell XML to ONLY SHOW [FIRSTNAME [LASTNAME] and CUSTOMFIELDS1 in the Print ..................................................................................

       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] => luizhas@gmail.com
                [ADDRESS1] => Cabo Frio
                [ADDRESS2] => 
                [CITY] => Cabo Frio
                [FULLSTATE] => RJ
                [STATE] => RJ
                [POSTCODE] => 28970000

                    [CUSTOMFIELDS1] => 28391656764
                    [CUSTOMFIELDS] => Array
                    (
  • 写回答

1条回答 默认 最新

  • dqst96444 2016-12-01 10:47
    关注

    Something like this probably works:

    echo $arr['WHMCSAPI']['CLIENT']['FIRSTNAME']
    echo $arr['WHMCSAPI']['CLIENT']['LASTNAME']
    echo $arr['WHMCSAPI']['CLIENT']['CUSTOMFIELDS1']
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀