function XML2JSON($xml)
{
    $result = array("ack" => (string) $xml->ack, "resultCount" => (string) $xml->paginationOutput->totalEntries, "pageNumber" => (string) $xml->paginationOutput->pageNumber, "itemCount" => (string) $xml->paginationOutput->entriesPerPage);
    $itemNum = (int) $xml->searchResult[0]['count'];
    for ($i = 0; $i < $itemNum; $i++) {
        $basicInfo = basic($xml, $i);
        $sellerInfo = seller($xml, $i);
        $shippingInfo = shipping($xml, $i);
        $info = array("basicInfo" => $basicInfo, "sellerInfo" => $sellerInfo, "shippingInfo" => $shippingInfo);
        $item = array("item" . $i => $info);
        $result = array_merge($result, $item);
    }
    echo json_encode($result);
}
Пример #2
0
function categoryname($category, $no)
{
    $jsondata = file_get_contents("http://api.pricecheckindia.com/feed/product/" . $category . ".json?user=ayushkr0&key=FQDFLHZVYOWKKVNK");
    $json1 = json_decode($jsondata, true);
    $b = 0;
    $count = 0;
    for ($i = 0; $i < $no; $i++) {
        $count++;
        $model = $json1['product'][$i]['model'];
        $brand = $json1['product'][$i]['brand'];
        //$ide = $json1['product'][$i]['id'];
        $producturl = "http://api.pricecheckindia.com/feed/product/" . $category . "/" . $brand . "+" . $model . ".json?user=ayushkr0&key=FQDFLHZVYOWKKVNK";
        $price = lowestprice($producturl);
        $web = seller($producturl);
        $img = $json1['product'][$i]['stores'][$b]['image'];
        if (!$img) {
            $img = "images/oos.png";
        }
        echo "<a href='search2.php?category=" . $category . "&item=" . $brand . "+" . $model . "' ><div class='col-md-2 container' style='width:240px;height:450px;'><div class='thumbnail'><img class='img-responsive' src=" . $img . "  style='object-fit: cover;overflow: hidden; padding:3px;' /><div class='caption'><center><p><h4>" . $brand . " " . $model . "</h4></p><p><h4>Rs. " . $price . "</h4></p><p><small>Seller :" . $web . "</small></p></center></div></div></div></a>";
    }
}