-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphoto.php
More file actions
331 lines (258 loc) · 13.6 KB
/
photo.php
File metadata and controls
331 lines (258 loc) · 13.6 KB
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>InstaFeed.me - Search Instagram profiles</title>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<!-- Custom styles for this template -->
<link href="css/stylesheet.css?version=1" rel="stylesheet">
<!-- Video player -->
<link href="http://vjs.zencdn.net/5.0.0/video-js.css" rel="stylesheet">
<!-- If you'd like to support IE8 -->
<script src="http://vjs.zencdn.net/ie8/1.1.0/videojs-ie8.min.js"></script>
</head>
<body>
<?php
include 'functions.php';
?>
<div class="wrapper">
<!-- Static navbar -->
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#search" aria-expanded="false" aria-controls="search">
<span class="sr-only">Toggle navigation</span>
<span class="glyphicon glyphicon-search"></span>
</button>
<a class="navbar-brand" href="index.php">InstaFeed.me</a>
</div>
<div class="photo-feed-wrapper">
<div id="navbar" class="collapse navbar-collapse">
<div class='hidden-xs'>
<ul class="nav navbar-nav">
<div class="search-box">
<form method='get' action='search.php'>
<div class="input-group stylish-input-group">
<input type="text" class="form-control" name='search_result' placeholder="User or Tag" value='pewdiepie'>
<span class="input-group-addon">
<button type="submit" name='submit'>
<span class="glyphicon glyphicon-search"></span>
</button>
</span>
</div>
</form>
</div>
</ul>
</div>
<ul class="nav navbar-nav navbar-right">
<?php isLoggedIn(); ?>
</ul>
</div><!--/.nav-collapse -->
<div class='visible-xs'>
<div id="search" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li>
<div class="search-box" class="collapse navbar-collapse">
<form method='get' action='search.php'>
<div class="input-group stylish-input-group">
<input type="text" class="form-control" name='search_result' placeholder="User or Tag" value='pewdiepie'>
<span class="input-group-addon">
<button type="submit" name='submit'>
<span class="glyphicon glyphicon-search"></span>
</button>
</span>
</div>
</form>
</div>
</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div><!--/.photo-feed-wrapper-collapse -->
</div><!--/.container-collapse -->
</nav>
<div class="container">
<!-- Main component for a primary marketing message or call to action -->
<?php
if(isset($_GET['photo'])){
$id = $_GET['photo'];
$url="https://api.instagram.com/v1/media/{$id}?access_token=".accessToken;
$get = connectToInstagram($url);
$obj = json_decode($get, true, 512);
$isValid = $obj['meta']['code'];
if(isset($obj['meta']['error_type'])){
$error_type = $obj['meta']['error_type'];
}
$length = count($obj['data']);
if($isValid !==400){
/*Show user profile data (pics, comments etc.)*/
$type = $obj['data']['type'];
$img = $obj['data']['images']['standard_resolution']['url'];
$comments_count = $obj['data']['comments']['count'];
if(isset($obj['data']['videos']['standard_resolution']['url'])){
$video = $obj['data']['videos']['standard_resolution']['url'];
}
$created_time = $obj['data']['created_time'];
$likes_count = $obj['data']['likes']['count'];
$filter = $obj['data']['filter'];
$profile_username = $obj['data']['user']['username'];
$profile_picture = $obj['data']['user']['profile_picture'];
$profile_full_name = $obj['data']['user']['full_name'];
$text = $obj['data']['caption']['text'];
$text = preg_replace("/#(\w+)/", "<a class='blue' a href='/instafeed/tag.php?tag=$1'>#$1</a>", $text);
$text = preg_replace("/@([^\s]+)/", "<a class='blue' href='/instafeed/profile.php?username=$1'>@$1</a>", $text);
$time = getTime($created_time);
?>
<div class='photo-feed-wrapper'>
<div class='row photo-wrapper'>
<!-- Photo box -->
<div class='media-box'>
<!-- Profile-box -->
<div class='profile-box'>
<div class='title-box-big'>
<div class='profile-picture'>
<?php echo "<a href='/instafeed/profile.php?username={$profile_username}'><img src='".$profile_picture."' alt='".$profile_username."' class='img-circle' height='40' width='40'></a>"; ?>
</div>
<div class='profile-top'>
<?php
echo "<span class='time'>{$time}</span>";
echo "<a href='/instafeed/profile.php?username={$profile_username}'><span class='name'>@".$profile_username."</span></a>";
echo "</div>";
echo "<div class='profile-bottom'>";
echo "<span class='time'>".$filter."</span>";
if($profile_full_name){
echo "<span class='name'>".$profile_full_name."</span>";
}
?>
</div>
</div> <!-- title-box end -->
<!-- Users liked photo -->
<?php
$j = 0;
echo "<div class='media-contents'>";
if($type == 'image'){
echo "<img class='center' src='".$img."' height='510' width='510'>";
}else{
echo "<video id='my-video' class='video-js' controls preload='auto' width='510' height='510' poster='MY_VIDEO_POSTER.jpg' data-setup='{}' style='margin: 0px auto;'>";
echo "<source src='".$video."' type='video/mp4'>";
echo "<source src='".$video."' type='video/webm'>"; //not .webm, change this?
echo "<p class='vjs-no-js'>";
echo "To view this video please enable JavaScript, and consider upgrading to a web browser that";
echo "<a href='http://videojs.com/html5-video-support/' target='_blank'>supports HTML5 video</a>";
echo "</p>";
echo "</video>";
}
echo "<div class='info-box'>";
echo "<span>".$likes_count." likes</span>";
echo "</div>"; /*<-- info-box end -->*/
/*Comment box*/
echo "<div class='comments-box'>";
echo "<div class='title-box'>";
echo "<div class='profile-picture'>";
echo "<a href='/instafeed/profile.php?username={$profile_username}'><img src='".$profile_picture."' alt='".$profile_username."' class='img-circle' height='32' width='32'></a>";
echo "</div>";
echo "<div class='profile-top'>";
echo "<h4>".$text."</h4>";
echo "</div>";
echo "</div>";
echo "<div class='comments-big'>";
echo "<p>".$comments_count." comments</p>";
echo "<ul class='commentList'>";
/*Show comments*/
$j = 0;
$commentsLength = count($obj['data']['comments']['data']);
//echo "<ul>";
while($j<$commentsLength){
$created_time = $obj['data']['comments']['data'][$j]['created_time'];
$text = $obj['data']['comments']['data'][$j]['text'];
$text = preg_replace("/#(\w+)/", "<a class='blue' a href='/instafeed/tag.php?tag=$1'>#$1</a>", $text);
$text = preg_replace("/@([^\s]+)/", "<a class='blue' href='/instafeed/profile.php?username=$1'>@$1</a>", $text);
$comment_username = $obj['data']['comments']['data'][$j]['from']['username'];
$comment_picture = $obj['data']['comments']['data'][$j]['from']['profile_picture'];
$comment_id = $obj['data']['comments']['data'][$j]['from']['id'];
$time = getTime($created_time);
echo "<li>";
echo "<div class='commenterImage'>";
echo "<a href='/instafeed/profile.php?username={$comment_username}'><img src='".$comment_picture."' alt='".$comment_username."' height='32' width='32'></a>";
echo "</div>";
echo "<div class='commentText'>";
echo "<p class=''><a href='/instafeed/profile.php?username={$comment_username}'>@".$comment_username."</a> ".$text."</p> <span class='date sub-text'>".$time."</span>";
echo "</div>";
echo "</li>";
$j++;
}
echo "</ul>";
echo "</div>";
echo "<form class='form-inline'' role='form'>";
echo "<div class='post-comment'>";
echo "<div class='form-group'>";
echo "<input class='form-control' type='text' placeholder='Add a comment...' />";
echo "</div>";
echo "<div class='form-group'>";
echo "<button class='btn btn-default'>Add</button>";
echo "</div>";
echo "</div>";
echo "</form>";
echo "</div>"; /*<-- comments-box end -->*/
echo "</div>"; /*<-- media-contents end -->*/
echo "</div>"; /*<-- media-content-big end -->*/
echo "</div>"; /*<-- row photo-wrapper end -->*/
echo "</div>";
echo "</div>"; /*<-- photo-feed-wrapper end -->*/
}else if($error_type == 'APINotFoundError'){
echo "<div class='photo-feed-wrapper'>";
echo "<div class='row photo-wrapper'>";
/*Photo box*/
echo "<div class='media-box'>";
/*Profile-box*/
echo "<div class='profile-box'>";
echo "<div class='center'>";
echo "<h2>Private profile, direct to profile by using _309165108 in the photo id</h2>";
echo "</div>"; /*<-- title-box end -->*/
echo "</div>"; /*<-- profile-box end -->*/
echo "</div>"; /*<-- media-box end -->*/
echo "</div>"; /*<-- row photo-wrapper end -->*/
echo "</div>"; /*<-- photo-feed-wrapper end -->*/
}else{
echo "<div class='photo-feed-wrapper'>";
echo "<div class='row photo-wrapper'>";
/*Photo box*/
echo "<div class='media-box'>";
/*Profile-box*/
echo "<div class='profile-box'>";
echo "<div class='center'>";
echo "<h2>Media could not be found</h2>";
echo "</div>"; /*<-- title-box end -->*/
echo "</div>"; /*<-- profile-box end -->*/
echo "</div>"; /*<-- media-box end -->*/
echo "</div>"; /*<-- row photo-wrapper end -->*/
echo "</div>"; /*<-- photo-feed-wrapper end -->*/
}
/*echo "<pre>";
print_r($obj);
echo "</pre>";*/
}
?>
</div> <!-- /container -->
<!-- <div class="top-button">
<h3><a href="#">^</a></h3>
</div> -->
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<!-- video player -->
<script src="http://vjs.zencdn.net/5.0.0/video.js"></script>
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</body>
</html>