-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_steamid.php
More file actions
76 lines (63 loc) · 2.82 KB
/
get_steamid.php
File metadata and controls
76 lines (63 loc) · 2.82 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
<?php
// Code by toxic1835 (-TOXIC-)
// if you dont know what to do write me AND ONLY CHANGE "CHANGE!" STRINGS
// Keep in mind: ";" ARE EVERYTHING if you forget one, your site will die xD
function discordCallback() {
$tokenUrl = 'https://discord.com/api/v10/oauth2/token';
$clientId = 'YOUR_CLIENT_ID'; // CHANGE!
$clientSecret = 'YOUR_CLIENT_SECRET'; // CHANGE!
$redirectUri = 'https://IP_OR_DOMAIN/callback.php'; // CHANGE!
if (isset($_GET['code'])) {
$authorizationCode = $_GET['code'];
$postData = array(
'client_id' => $clientId,
'client_secret' => $clientSecret,
'grant_type' => 'authorization_code',
'code' => $authorizationCode,
'redirect_uri' => $redirectUri,
'scope' => 'identify connections'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $tokenUrl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$accessTokenData = json_decode($response, true);
if (isset($accessTokenData['access_token'])) {
$accessToken = $accessTokenData['access_token'];
$userUrl = 'https://discord.com/api/v10/users/@me';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $userUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $accessToken));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$userInfo = curl_exec($ch);
curl_close($ch);
$connectionsUrl = 'https://discord.com/api/v10/users/@me/connections';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $connectionsUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $accessToken));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$connectionsInfo = curl_exec($ch);
curl_close($ch);
$steamidFound = false;
$connectionsData = json_decode($connectionsInfo, true);
foreach ($connectionsData as $connection) {
if ($connection['type'] === 'steam') {
echo 'SteamID: ' . $connection['id'];
$steamidFound = true;
}
}
if (!$steamidFound) {
echo 'The system couldn\'t find steam in your profile connections!';
}
} else {
echo 'There was an error getting you discord account.';
}
} else {
echo 'No Authentification-Code set!';
}
}
discordCallback();
?>