第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何從 API 響應(yīng)生成動(dòng)態(tài) Ul li(列表項(xiàng))?

如何從 API 響應(yīng)生成動(dòng)態(tài) Ul li(列表項(xiàng))?

PHP
UYOU 2023-05-26 16:31:14
我正在運(yùn)行 API 調(diào)用并獲得以下響應(yīng):{"recsonpage":"4",    "4":{        "orders.orderid":"8890348189",        "entity.customerid":"15250457",        "entity.entityid":"88908189",        "orders.autorenew":"false",        "orders.endtime":"1604899485",        "orders.resellerlock":"false",        "orders.timestamp":"2019-11-09 05:24:46.25876+00",        "orders.customerlock":"true",        "entity.entitytypeid":"3",        "entity.currentstatus":"Active",        "entitytype.entitytypekey":"domcno",        "orders.transferlock":"true",        "orders.creationtime":"1573277085",        "orders.privacyprotection":"false",        "entitytype.entitytypename":".COM Domain Name",        "orders.creationdt":"1573277084",        "entity.description":"domain1.com"        },    "3":{        "orders.orderid":"8739268259",        "entity.customerid":"15250457",        "entity.entityid":"87398259",        "orders.autorenew":"false",        "orders.endtime":"1625211562",        "orders.resellerlock":"false",        "orders.timestamp":"2020-05-23 05:53:15.586565+00",        "orders.customerlock":"true",        "entity.entitytypeid":"3",        "entity.currentstatus":"Active",        "entitytype.entitytypekey":"domcno",        "orders.transferlock":"true",        "orders.creationtime":"1372750762",        "orders.privacyprotection":"false",        "entitytype.entitytypename":".COM Domain Name",        "orders.creationdt":"1561992837",        "entity.description":"domain2.com"        },    "2":{        "orders.orderid":"8739768158",        "entity.customerid":"15250457",        "entity.entityid":"87398158",        "orders.autorenew":"false",        "orders.endtime":"1625300828",        "orders.resellerlock":"false",        "orders.timestamp":"2020-05-23 05:54:20.869807+00",        "orders.customerlock":"true",        "entity.entitytypeid":"17",        "entity.currentstatus":"Active",        },該按鈕被單擊 4 次(來(lái)自 API 的行數(shù))以生成列表項(xiàng)。但問(wèn)題是我無(wú)法在每個(gè)列表中獲取不同的數(shù)據(jù)。我在每個(gè)列表項(xiàng)中都得到相同的數(shù)據(jù)。請(qǐng)幫忙。
查看完整描述

1 回答

?
滄海一幻覺(jué)

TA貢獻(xiàn)1824條經(jīng)驗(yàn) 獲得超5個(gè)贊

您不需要為此目的添加隱藏按鈕,也不需要添加 jQuery 代碼。當(dāng)頁(yè)面加載時(shí),您的 API 已經(jīng)被調(diào)用并且結(jié)果已經(jīng)存在,以便在頁(yè)面加載 UI 之前呈現(xiàn)。所以我們需要遍歷從 API 接收到的數(shù)據(jù)并呈現(xiàn) UI。


試試下面的代碼塊:


<?php

global $user_ID, $user_identity, $userdata; wp_get_current_user();

$current_user = wp_get_current_user();

$custemail= $current_user->user_email;

get_header();

$url = 'https://httpapi.com/api/customers/details.json?auth-userid=12345&api-key=mykey&username='.$custemail;

$ch = curl_init($url);

curl_setopt($ch, CURLOPT_TIMEOUT, 5);

curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$json = curl_exec($ch);

if(curl_error($ch)) { 

    echo 'error:' . curl_error($ch);

};

curl_close($ch);

$data = json_decode($json,true);

$custid = $data['customerid'];

$url = 'https://httpapi.com/api/domains/search.json?auth-userid=12345&api-key=mykey&no-of-records=10&page-no=1&customer-id='.$custid;

$ch = curl_init($url);

curl_setopt($ch, CURLOPT_TIMEOUT, 5);

curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$json = curl_exec($ch);

if(curl_error($ch)) { 

    echo 'error:' . curl_error($ch);

};

curl_close($ch);

$data = json_decode($json,true);

ksort($data);

?>

<div>

    <ul id="dom-list" class="domain-list-ul">

        <?php foreach($data as $key => $value) { ?>

        <?php if(is_array($value)) { ?>

        <li>

            <p class="tld-name-2">

                <?php echo " {$value['entity.description']}"; ?>

            </p>

            <p class="prop">

                <span class="prop-head">Created On :</span>

                <span class="data-no"><?php echo " {$value['orders.creationtime']}"; ?></span>

            </p>

            <p class="prop">

                <span class="prop-head">Expires On :</span>

                <span class="data-no"><?php echo " {$value['orders.endtime']}"; ?></span>

            </p>

            <p class="prop">

                <span class="prop-head">Privacy Protection :</span>

                <span class="data-no"><?php echo " {$value['orders.privacyprotection']}"; ?></span>

            </p>

            <p class="prop">

                <span class="prop-head">Theft Protection :</span>

                <span class="data-no"><?php echo " {$value['orders.customerlock']}"; ?></span>

            </p>

            <p class="prop">

                <span class="prop-head">Status :</span>

                <span class="data-no"><?php echo " {$value['entity.currentstatus']}"; ?></span>

            </p>

        </li>

        <?php }  

} ?>

    </ul>

</div>


查看完整回答
反對(duì) 回復(fù) 2023-05-26
  • 1 回答
  • 0 關(guān)注
  • 193 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)