Follow along with the video below to see how to install our site as a web app on your home screen.
Бележка: This feature may not be available in some browsers.
Ти реално нищо не си обяснил?GOTI каза:Никой ли не разбира от API...![]()
<?php
$secret= "blablabla";
$apiurl = "http://domein.com/api/collections?app_id=20&secret=blablabla".$secret."&limit=28&keywords=final%20fantasy";
$cachetime = @filemtime("cache.json");
$diff = time() - $cachetime;
if($diff <= 60*60) {
$results = json_decode(file_get_contents("cache.json"));
$products = objectToArray($results);
} else {
$products = array();
$results = json_decode(file_get_contents($apiurl));
$i = 0;
foreach($results->results as $product){
$products[$i]["pid"] = $product->listing_id;
$products[$i]["title"] = $product->title;
$products[$i]["url"] = $product->url;
$products[$i]["price"] = $product->price;
$products[$i]["quantity"] = $product->quantity;
$products[$i]["endtime"] = $product->ending_tsz;
$imgs = json_decode(file_get_contents("http://domein.com/api/collections?app_id=20".$product->listing_id."/images?api_key=".$secret));
$products[$i]["thumb"] = $imgs->results[0]->url_800x600;
$products[$i]["image"] = $imgs->results[0]->url_570xN;
$i++;
}
$jsonified = json_encode($products);
$jsoncache = "cache.json";
$fp = fopen($jsoncache, "w");
fwrite($fp, $jsonified);
fclose($fp);
}
function objectToArray($d) {
if (is_object($d)) {
$d = get_object_vars($d);
}
if (is_array($d)) {
return array_map(__FUNCTION__, $d);
}
else {
return $d;
}
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Demo Api</title>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
</head>
<body>
<div id="w">
<h1>Demo API</h1>
<div id="products" class="clearfix">
<?php
foreach($products as $product) {
echo "<div class=\"product\">\n";
echo "<h2><a href=\"".$product['url']."\" target=\"_blank\">".$product['title']."</a></h2>\n";
echo "<center><a href=\"".$product['url']."\" target=\"_blank\"><img src=\"".$product['thumb']."\" alt=\"".$product['title']." featured image\" class=\"thumb\"></a></center>\n";
echo "<p>Price: <span class=\"price\">$".$product['price']."</span></p>\n";
echo "<p>Quantity: ".$product['quantity']."</p>\n";
echo "</div>\n";
}
?>
</div>
</div>
</body>
</html>