-
Notifications
You must be signed in to change notification settings - Fork 1
/
phpfunctions.php
133 lines (88 loc) · 3.73 KB
/
phpfunctions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<!--phpfunctions.php Page-->
<?php
//Function To Return Lowest Price Of a Product by Comparing prices of the product from various shopping website
function lowestprice($url) {
$a = 0;
$prodata = file_get_contents($url);
$pro = json_decode($prodata,true);
$count = count($pro['product'][$a]['stores']);
$low = $pro['product'][$a]['stores'][$a]['price'];
for($j=1;$j<$count;$j++) {
$p = $pro['product'][$a]['stores'][$j]['price'];
if($low > $p) {
$low = $p;
}
}
return $low;
}
//End Of Function lowestprice()
//Funtion to retrieve all deatils of a products
function searchbykeyword($category,$product) {
$a=0;
$url = "http://api.pricecheckindia.com/feed/product/".$category."/".$product.".json?user=ayushkr0&key=FQDFLHZVYOWKKVNK";
$itemcoded = file_get_contents($url);
$item = json_decode($itemcoded,true);
$counts= count($item['product'][$a]['stores']);
if($counts<=0) {
echo "<div style='padding-top:170px;'><h1>No Result Found For ".$product."</h1></div>";
}
else
{
$img = $item['product'][$a]['stores'][$a]['image'];
if(!$img) {
$img = "images/oos.png";
}
$model = $item['product'][$a]['model'];
$brand = $item['product'][$a]['brand'];
//$id = $item['product']['id'];
$web = $item['product'][$a]['stores'][$a]['website'];
$price = lowestprice($url);
echo '<div class="thumbnail">';
echo "<div class='caption'><h2>".$brand."+".$model."</h2></div>";
echo "<img src=".$img." />";
echo "<div class='caption' ><p><h3>Lowest Price : Rs. ".$price."</h3></p><small>Seller : ".$web."</small></div></div>";
}
}
//End Of function searchbykeyword()
//Function to retrieve products information category wish
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>";
}
}
//End of function categoryname
//Function to retrieve seller selling the product in lowest price compare to other
function seller($url) {
$a = 0;
$prodata = file_get_contents($url);
$pro = json_decode($prodata,true);
$count = count($pro['product'][$a]['stores']);
$low = $pro['product'][$a]['stores'][$a]['price'];
$web = $pro['product'][$a]['stores'][$a]['website'];
for($j=1;$j<$count;$j++) {
$p = $pro['product'][$a]['stores'][$j]['price'];
if($web > $p) {
$low= $p;
$web = $pro['product'][$a]['stores'][$j]['website'];
}
}
return $web;
}
//End Of seller()
?>
<!--End Of phpfunctions.php-->