-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
160 lines (148 loc) · 7 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
<?php
$username = null;
function scrape_insta($username) {
$insta_source = file_get_contents('https://www.instagram.com/'.$username);
$shards = explode('window._sharedData = ', $insta_source);
$insta_json = explode(';</script>', $shards[1]);
$insta_array = json_decode($insta_json[0], TRUE);
return $insta_array;
}
if (isset($_GET['username'])) {
$username = $_GET['username'];
$results_array = scrape_insta($username)['entry_data']['ProfilePage'][0]['graphql']['user'];
$linkAccount = 'http://instagram.com/'.$username;
$id = $results_array['id'];
$end_cursor = str_replace('==', '', $results_array['edge_owner_to_timeline_media']['page_info']['end_cursor']);
$fullname = $results_array['full_name'];
$listPost = $results_array['edge_owner_to_timeline_media']['edges'];
$profile_pic = $results_array['profile_pic_url_hd'];
$follower = $results_array['edge_followed_by']['count'];
$following = $results_array['edge_follow']['count'];
$countPost = $results_array['edge_owner_to_timeline_media']['count'];
$biography = $results_array['biography'];
$mainPath = '/'.explode('/', dirname($_SERVER['PHP_SELF']))[1];
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Profile | Vietgram</title>
<script src="https://rawgit.com/jackmoore/autosize/master/dist/autosize.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="./asset/css/styles.css">
<link rel="stylesheet" href="./asset/css/custom.css">
</head>
<body>
<nav class="navigation">
<div class="navigation__column">
<a href='http://instagram.com/'>
<img src="images/logo.png" />
</a>
</div>
<div class="navigation__column">
<form action="" method="get">
<label for="submit"><i class="fa fa-search"></i></label>
<input type="text" name="username" placeholder="Search" <?=($username == null ? 'autofocus' : '')?>>
<button id="submit" type="submit" style="display: none;"></button>
</form>
</div>
<div class="navigation__column">
<ul class="navigations__links">
<li class="navigation__list-item">
<a <?=(isset($linkAccount) ? "href=\"$linkAccount\"" : '')?> class="navigation__link" target="_blank" rel="noopener" disabled>
<i class="fa fa-user-o fa-lg"></i>
</a>
</li>
</ul>
</div>
</nav>
<?php if ($username != null):?>
<main id="profile">
<header class="profile__header">
<div class="profile__column">
<img src="<?=$profile_pic?>" width="150px" />
</div>
<div class="profile__column">
<div class="profile__title">
<h3 class="profile__username"><?=$username?></h3>
<!-- <a href="edit-profile.html">Edit profile</a> -->
<!-- <i class="fa fa-cog fa-lg"></i> -->
</div>
<ul class="profile__stats">
<li class="profile__stat">
<span class="stat__number"><?=$countPost?></span> posts
</li>
<li class="profile__stat">
<span class="stat__number"><?=$follower?></span> followers
</li>
<li class="profile__stat">
<span class="stat__number"><?=$following?></span> following
</li>
</ul>
<p class="profile__bio">
<span class="profile__full-name">
<?=$fullname?>
<br>
</span>
<textarea id="bio" name="" readonly><?=$biography?></textarea>
</p>
</div>
</header>
<section class="profile__photos" id="allPost">
<?php
foreach ($listPost as $key => $value):
?>
<div class="profile__photo <?=$key == 8 ? 'offset1' : ''?>">
<div class="image" style="background-image:url('<?=$value['node']['display_url']?>');"> </div>
<div class="profile__photo-overlay">
<span class="overlay__item">
<i class="fa fa-heart"></i>
<?=$value['node']['edge_liked_by']['count']?>
</span>
<span class="overlay__item">
<i class="fa fa-comment"></i>
<?=$value['node']['edge_media_to_comment']['count']?>
</span>
</div>
</div>
<?php
endforeach;
?>
</section>
</main>
<footer class="footer">
<div class="footer__column">
<nav class="footer__nav">
<ul class="footer__list">
<li class="footer__list-item"><a href="#" class="footer__link">About Us</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Support</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Blog</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Press</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Api</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Jobs</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Privacy</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Terms</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Directory</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Language</a></li>
</ul>
</nav>
</div>
<div class="footer__column">
<span class="footer__copyright">© 2020 Instagram</span>
</div>
</footer>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
autosize(document.getElementById('bio'))
let id_user = '<?=$id?>'
let end_cursor = '<?=$end_cursor?>'
let mainPath = '<?=$mainPath?>'
</script>
<script src="./asset/script/script.js"></script>
<?php else:?>
<?php endif;?>
</body>
</html>