-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.php
206 lines (178 loc) · 5.04 KB
/
index.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<?php
include_once("snapdealApiClass.php");
// Get affiliateID and token from https://affiliate.snapdeal.com
// Set snapdeal affiliateID and token
$affiliateID = 'YOUR_AFFILIATE_ID';
$token = 'YOUR_TOKEN';
$sdObj = new snapdealApi($affiliateID, $token);
?>
<title>Snapdeal Affiliate API DEMO</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<style>
.glyphicon { margin-right:5px; }
.thumbnail
{
margin-bottom: 20px;
padding: 0px;
-webkit-border-radius: 0px;
-moz-border-radius: 0px;
border-radius: 0px;
}
.item.list-group-item
{
float: none;
width: 100%;
background-color: #fff;
margin-bottom: 10px;
}
.item.list-group-item:nth-of-type(odd):hover,.item.list-group-item:hover
{
background: #428bca;
}
.item.list-group-item .list-group-image
{
margin-right: 10px;
}
.item.list-group-item .thumbnail
{
margin-bottom: 0px;
}
.item.list-group-item .caption
{
padding: 9px 9px 0px 9px;
}
.item.list-group-item:nth-of-type(odd)
{
background: #eeeeee;
}
.item.list-group-item:before, .item.list-group-item:after
{
display: table;
content: " ";
}
.item.list-group-item img
{
float: left;
}
.item.list-group-item:after
{
clear: both;
}
.list-group-item-text
{
margin: 0 0 11px;
}
</style>
<style>
.card {
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12);
}
.card {
margin-top: 10px;
box-sizing: border-box;
border-radius: 2px;
background-clip: padding-box;
}
.card span.card-title {
color: #fff;
font-size: 24px;
font-weight: 300;
text-transform: uppercase;
}
.card .card-image {
position: relative;
overflow: hidden;
}
.card .card-image img {
border-radius: 2px 2px 0 0;
background-clip: padding-box;
position: relative;
z-index: -1;
}
.card .card-image span.card-title {
position: absolute;
bottom: 0;
left: 0;
padding: 16px;
}
.card .card-content {
padding: 16px;
border-radius: 0 0 2px 2px;
background-clip: padding-box;
box-sizing: border-box;
}
.card .card-content p {
margin: 0;
color: inherit;
}
.card .card-content span.card-title {
line-height: 48px;
}
.card .card-action {
border-top: 1px solid rgba(160, 160, 160, 0.2);
padding: 16px;
}
.card .card-action a {
color: #ffab40;
margin-right: 16px;
transition: color 0.3s ease;
text-transform: uppercase;
}
.card .card-action a:hover {
color: #ffd8a6;
text-decoration: none;
}
</style>
<div class="container">
<h1 style="text-align:center">Snapdeal Affiliate API DEMO <br/>
<?php if(isset($_GET['category'])) { ?>
<a href="index.php">(All Categories)</a>
<br/>
<?= strtoupper(str_replace("_", " ",$_GET['category'])) ?>
<?php } else { ?>
(All Categories)
<?php } ?>
</h1>
<?php if(isset($_GET['category']) && isset($_GET['url'])) { ?>
<div id="products" class="row list-group">
<?php
// snapdeal product feed url
$url = base64_decode($_GET['url']);
$result = snapdealApi::getData($url, 'json');
foreach($result['products'] as $resultSet) {
?>
<div class="item col-sm-6 col-md-3" style="height:400px;">
<div class="thumbnail" >
<img class="group list-group-image" src="<?= $resultSet['imageLink']; ?>" alt="" style="height:200px; width:200px;" />
<div class="caption">
<h4 class="group inner list-group-item-heading">
<?= $resultSet['title']; ?></h4>
<p class="group inner list-group-item-text" style="color:red">
<b><?= $resultSet['availability']; ?></b></p>
<p style="color:green"><b>Offer Price: Rs. <?= $resultSet['offerPrice'] ?></b></p>
<div class="row">
<div class="col-xs-12 col-md-12">
<a class="btn btn-lg btn-success deal" target="_blank" style="width:100%" rel="nofollow, noindex" href="<?= $resultSet['link']; ?>"><b>VIEW ON SNAPDEAL</b></a>
</div>
</div>
</div>
</div>
</div>
<?php } ?>
</div>
<?php } else {
// snapdeal product feed url
$url = 'http://affiliate-feeds.snapdeal.com/feed/72967.json';
$result = snapdealApi::getData($url, 'json');
?>
<div class="row">
<?php foreach($result['apiGroups']['Affiliate']['listingsAvailable'] as $cat => $val) { ?>
<div class="col-md-4 card" style="height:80px;">
<a href="index.php?category=<?= $cat ?>&url=<?= base64_encode($val['listingVersions']['v1']['get']); ?>" ><b><h3><?= strtoupper(str_replace('_', ' ', $cat)) ?></h3></b></a>
</div>
<?php } } ?>
</div>
}
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>