-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfriendactivity.php
More file actions
126 lines (93 loc) · 4.62 KB
/
friendactivity.php
File metadata and controls
126 lines (93 loc) · 4.62 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
<?php
session_start();
if(!$_SESSION['spdcsession']){
header('Location: index.php');
}
include("functions.php");
date_default_timezone_set('Europe/Istanbul');
$spdc = $_SESSION['spdcsession'];
// get access token with sp_dc cookie //
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://open.spotify.com/get_access_token?reason=transport&productType=web_player');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$headers = [
'Cookie: sp_dc='.$spdc.'',
'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:28.0) Gecko/20100101 Firefox/28.0',
'Accept: application/json'
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$calistir = curl_exec($ch);
curl_close($ch);
$json = json_decode($calistir);
$accessToken = $json->accessToken;
// get access token with sp_dc cookie //
// get buddylist with access token //
$ch2 = curl_init();
curl_setopt($ch2, CURLOPT_URL, 'https://guc-spclient.spotify.com/presence-view/v1/buddylist');
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch2, CURLOPT_SSL_VERIFYPEER, false);
$headers2 = [
'Authorization: Bearer '.$accessToken.'',
'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:28.0) Gecko/20100101 Firefox/28.0',
'Accept: application/json'
];
curl_setopt($ch2, CURLOPT_HTTPHEADER, $headers2);
$calistir2 = curl_exec($ch2);
curl_close($ch2);
$json2 = json_decode($calistir2);
// print_r($json2->friends['0']); --> to access a single user information
$toplamarkadas = count($json2->friends);
// get buddylist with access token //
?>
<!DOCTYPE html>
<html lang="tr">
<head>
<meta charset="UTF-8">
<title>SpotiBuddy</title>
<meta name="viewport" content="width=device-width, initial-scale=1"><link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css'>
<link rel="icon" href="https://www.freepnglogos.com/uploads/spotify-logo-png/spotify-icon-marilyn-scott-0.png" type="image/x-icon" />
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css'>
<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Cabin'><link rel="stylesheet" href="./style.css">
</head>
<body>
<div class="container">
<br>
<center><img width="5%" src="https://www.freepnglogos.com/uploads/spotify-logo-png/spotify-download-logo-30.png"><a style="font-size:25px;color:black" href="index.php">SpotiBuddy</a></center>
<div class="row">
<div class="col-md-12">
<div id="output">
<center><font style="color: white">Arkadaşlarım Ne Dinliyor? (<?php echo $toplamarkadas; ?> kullanıcı)</font></center>
<?php
for ($i = $toplamarkadas-1; $i >= 0; $i--) { ?>
<div class="row friend">
<a target="_blank" href="<?php print_r($json2->friends[$i]->user->uri); ?>"><img src="<?php if(!empty($json2->friends[$i]->user->imageUrl)){ print_r($json2->friends[$i]->user->imageUrl); } else { print_r("profile.jpg"); } ?>" alt="profile photo"></a>
<div class="title">
<a target="_blank" style="color:white" href="<?php print_r($json2->friends[$i]->user->uri); ?>"><?php print_r($json2->friends[$i]->user->name); ?></a>
<br>
<a target="_blank" style="color:white" href="<?php print_r($json2->friends[$i]->track->uri); ?>"><?php print_r($json2->friends[$i]->track->name); ?></a> - <a target="_blank" style="color:white" href="<?php print_r($json2->friends[$i]->track->artist->uri); ?>"><?php print_r($json2->friends[$i]->track->artist->name); ?></a> <a target="_blank" style="color:white" href="<?php print_r($json2->friends[$i]->track->context->uri); ?>">(<?php print_r($json2->friends[$i]->track->context->name); ?>) 🎵</a>
<br>
</div><?php
$mil = $json2->friends[$i]->timestamp;
$seconds = $mil / 1000; // converting ms unix timestamp to normal date
echo get_time_ago($seconds); // convert timestamp to time ago type
?>
</div>
<?php }
?>
<center><a href="index.php" class="btn btn-light">Çıkış Yap</a></center>
</div>
</div>
</div>
</div>
<center>SpotiBuddy © 2021
<br>
<a target="_blank" style="color:black" href="https://mertpolat.com.tr">Developer</a>
</center>
<br>
<!-- partial -->
<!-- <script src='https://code.jquery.com/jquery-3.2.1.slim.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js'></script>
<script src='https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js'></script><script src="./script.js"></script> -->
</body>
</html>