-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgetToken.php
More file actions
30 lines (26 loc) · 844 Bytes
/
getToken.php
File metadata and controls
30 lines (26 loc) · 844 Bytes
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
<?php
$clientId = 'oiaj85u4lww35nv6eco0yrq5g3zibv';
$tokenAPI = 'https://id.twitch.tv/oauth2/token
--data-urlencode
?grant_type=refresh_token
&refresh_token=eyJfaWQmNzMtNGCJ9%6VFV5LNrZFUj8oU231/3Aj
&client_id=fooid
&client_secret=barbazsecret';
$data = array (
'client_id' => $clientId,
'client_secret' => '1mb2v2fciec6b6z4hck8tkozvvhjf8',
'grant_type' => 'client_credentials'
);
$post_data = json_encode($data);
$crl = curl_init('https://id.twitch.tv/oauth2/token');
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLINFO_HEADER_OUT, true);
curl_setopt($crl, CURLOPT_POST, true);
curl_setopt($crl, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($crl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json'
));
$result = curl_exec($crl);
$result = json_decode($result);
curl_close($crl);
var_dump($result);