Example #1
0
function apiGet($CidIn, $theP, $keyW)
{
    //$input:cat)
    include_once rootD . "/api/TopSdk.php";
    $c = new TopClient();
    $c->appkey = "23167663";
    //appkey及secretkey
    $c->secretKey = "e1980a4313fb60fb61a43d694066c8a3";
    $req1 = new TbkItemsGetRequest();
    $req1->setFields("num_iid,title,volume,pic_url,item_url,shop_url,nick");
    $req1->setKeyword($keyW);
    $req1->setCid($CidIn);
    $req1->setStartPrice("2");
    $req1->setEndPrice("9000000");
    $req1->setStartCredit("2heart");
    $req1->setEndCredit("5goldencrown");
    $req1->setSort("commissionNum_desc");
    $req1->setMallItem("false");
    $req1->setStartCommissionRate("500");
    $req1->setEndCommissionRate("5000");
    $req1->setStartCommissionNum("20");
    $req1->setEndCommissionNum("9000000");
    $req1->setStartTotalnum("50");
    $req1->setEndTotalnum("9000000");
    $req1->setPageNo($theP);
    $req1->setPageSize(40);
    $resp1 = $c->execute($req1);
    $resp1 = (array) $resp1;
    $resp1["tbk_items"] = (array) $resp1["tbk_items"];
    for ($j = 0; $j < 40; $j++) {
        $resp1["tbk_items"]["tbk_item"][$j] = (array) $resp1["tbk_items"]["tbk_item"][$j];
    }
    $req2 = new TbkItemInfoGetRequest();
    for ($k = 0; $k < 40; $k++) {
        $NumIIdGet = $resp1["tbk_items"]["tbk_item"][$k]["num_iid"];
        $req2->setFields("zk_final_price,provcity,reserve_price");
        $req2->setNumIids($NumIIdGet);
        $resp2 = $c->execute($req2);
        $resp2 = (array) $resp2;
        $resp2["results"] = (array) $resp2["results"];
        $resp2["results"]["n_tbk_item"] = (array) $resp2["results"]["n_tbk_item"];
        $resp2["results"]["n_tbk_item"][0] = (array) $resp2["results"]["n_tbk_item"][0];
        $re["i"][$k] = $resp1["tbk_items"]["tbk_item"][$k] + $resp2["results"]["n_tbk_item"][0];
    }
    $re["t"] = $resp1["total_results"];
    return $re;
}
Example #2
0
function showSearch($keywords, $theP)
{
    include_once rootD . "/api/TopSdk.php";
    $c = new TopClient();
    $c->appkey = "23167663";
    //appkey及secretkey
    $c->secretKey = "e1980a4313fb60fb61a43d694066c8a3";
    $req1 = new TbkItemsGetRequest();
    $req1->setFields("num_iid,title,volume,pic_url,item_url,shop_url,nick");
    $req1->setKeyword($keywords);
    $req1->setStartPrice("2");
    $req1->setEndPrice("9000000");
    $req1->setStartCredit("1heart");
    $req1->setEndCredit("5goldencrown");
    $req1->setSort("commissionNum_desc");
    $req1->setMallItem("false");
    $req1->setStartCommissionRate("500");
    $req1->setEndCommissionRate("5000");
    $req1->setStartCommissionNum("20");
    $req1->setEndCommissionNum("9000000");
    $req1->setStartTotalnum("50");
    $req1->setEndTotalnum("9000000");
    $req1->setPageNo($theP);
    $req1->setPageSize(30);
    $resp1 = $c->execute($req1);
    $resp1 = (array) $resp1;
    $resp1["tbk_items"] = (array) $resp1["tbk_items"];
    for ($j = 0; $j < 30; $j++) {
        $resp1["tbk_items"]["tbk_item"][$j] = (array) $resp1["tbk_items"]["tbk_item"][$j];
    }
    $req2 = new TbkItemInfoGetRequest();
    for ($k = 0; $k < 30; $k++) {
        $NumIIdGet = $resp1["tbk_items"]["tbk_item"][$k]["num_iid"];
        $req2->setFields("zk_final_price,provcity,reserve_price");
        $req2->setNumIids($NumIIdGet);
        $resp2 = $c->execute($req2);
        $resp2 = (array) $resp2;
        $resp2["results"] = (array) $resp2["results"];
        $resp2["results"]["n_tbk_item"] = (array) $resp2["results"]["n_tbk_item"];
        $resp2["results"]["n_tbk_item"][0] = (array) $resp2["results"]["n_tbk_item"][0];
        $re["i"][$k] = $resp1["tbk_items"]["tbk_item"][$k] + $resp2["results"]["n_tbk_item"][0];
    }
    $re["t"] = $resp1["total_results"];
    $totlePages = ceil($re["t"] / 30) <= 10 ? ceil($re["t"] / 30) <= 10 : 10;
    $pageg = $theP;
    //print_r ($re);
    if ($re["t"] == 0) {
        echo "<center style=\"margin:50px auto;font-size:20px;color:#F93;padding:10px;border:1px #898989 solid;border-radius:5px;width:310px;\">这里空空如也  Σ( ° △ °|||)︴</center>";
    } else {
        for ($z = 0; $z < 30; $z++) {
            echo "<div class='unitDiv'><ul class=unitUl>";
            echo "<li>";
            echo "<a href='" . $re["i"][$z]["item_url"] . "' title='" . $re["i"][$z]["title"] . "--" . $re["i"][$z]["nick"] . "--" . $re["i"][$z]["provcity"] . "'><img class='pics' src='" . $re["i"][$z]["pic_url"] . "'style='height:280px;' /></a>";
            echo "</li>";
            echo "<li class='itemNameLi'>";
            echo "<a href='" . $re["i"][$z]["item_url"] . "'><span class='itemName'>" . $re["i"][$z]["title"] . "</span></a>";
            echo "</li>";
            echo "<li>";
            echo "<ul class='detls'>";
            echo "<li class='inlineLi'>";
            echo "<span class='disPrice'>¥" . $re["i"][$z]["reserve_price"] . "</span>";
            echo "</li>";
            echo "<li class='inlineLi'>";
            echo "<s class='price'>" . $re["i"][$z]["reserve_price"] . "</s>";
            echo "</li>";
            echo "<li class='inlineLi' id='salesLi'>";
            echo "<span class='sales'>" . "月销" . $re["i"][$z]["volume"] . "件" . "</span>";
            echo "</li>";
            echo "</ul>";
            echo "</li>";
            echo "</ul></div>";
            unset($re["i"][$z]);
        }
        echo "<ul id=\"sepage\">";
        $url = thisU . "?s={$keywords}&p=";
        $pageb = "";
        if ($pageg > 1) {
            $pageb .= "<li><a href={$url}" . ($pageg - 1) . ">上一页</li>";
        }
        if ($pageg <= 3) {
            $pageb .= "<li><a href={$url}" . 1 . ">1</li>";
            if ($totlePages >= 2) {
                $pageb .= "<li><a href={$url}" . 2 . ">2</li>";
            }
            if ($totlePages >= 3) {
                $pageb .= "<li><a href={$url}" . 3 . ">3</li>";
            }
            if ($totlePages >= 4) {
                $pageb .= "<li><a href={$url}" . 4 . ">4</li>";
            }
            if ($totlePages >= 5) {
                $pageb .= "<li><a href={$url}" . 5 . ">5</li>";
            }
        }
        if ($pageg > 3 && $pageg < $totlePages - 2) {
            $pageb .= "<li><a href={$url}" . ($pageg - 2) . ">" . ($pageg - 2) . "</li>";
            $pageb .= "<li><a href={$url}" . ($pageg - 1) . ">" . ($pageg - 1) . "</li>";
            $pageb .= "<li><a href={$url}" . $pageg . ">{$pageg}</li>";
            $pageb .= "<li><a href={$url}" . ($pageg + 1) . ">" . ($pageg + 1) . "</li>";
            $pageb .= "<li><a href={$url}" . ($pageg + 2) . ">" . ($pageg + 2) . "</li>";
        }
        if ($pageg >= $totlePages - 2) {
            $pageb .= "<li><a href={$url}" . ($totlePages - 4) . ">" . ($totlePages - 4) . "</li>";
            $pageb .= "<li><a href={$url}" . ($totlePages - 3) . ">" . ($totlePages - 3) . "</li>";
            $pageb .= "<li><a href={$url}" . ($totlePages - 2) . ">" . ($totlePages - 2) . "</li>";
            $pageb .= "<li><a href={$url}" . ($totlePages - 1) . ">" . ($totlePages - 1) . "</li>";
            $pageb .= "<li><a href={$url}" . $totlePages . ">{$totlePages}</li>";
        }
        if ($pageg < $totlePages) {
            $pageb .= "<li><a href={$url}" . ($pageg + 1) . ">下一页</li>";
        }
        $pageb .= "<li><a href={$url}" . $totlePages . "><span>共{$totlePages}页</span></a></li>";
        echo $pageb;
        echo "</ul>";
    }
}