This repository was archived by the owner on May 2, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtwitchoverlay.php
More file actions
63 lines (49 loc) · 1.28 KB
/
Copy pathtwitchoverlay.php
File metadata and controls
63 lines (49 loc) · 1.28 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
<?php
$a = $_GET['a'];
$client_id = '<app client id>';
$client_secret = '<app client secret>';
function authenticate()
{
global $client_id, $client_secret;
$code = $_GET['code'];
$scope = $_GET['scope'];
$url = 'https://id.twitch.tv/oauth2/token';
$fields = array(
'client_id' => $client_id,
'client_secret' => $client_secret,
'code' => $code,
'grant_type' => 'authorization_code',
'redirect_uri' => 'http://dawnnest.com/twitchoverlay.php'
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
print $response;
}
function refresh()
{
global $client_id, $client_secret;
$token = $_GET['refresh'];
$url = 'https://id.twitch.tv/oauth2/token';
$fields = array(
'client_id' => $client_id,
'client_secret' => $client_secret,
'refresh_token' => $token,
'grant_type' => 'refresh_token'
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
print $response;
}
if( $a == 'refresh' )
refresh();
else
authenticate();
?>