Definitely think I’m missing something here…
========== VALIDATION Data ==========
Array
(
[client_id] => <redacted>
[login] => zoeballz
[scopes] => Array
(
[0] => openid
[1] => user:manage:blocked_users
[2] => user:read:blocked_users
)
[user_id] => <redacted>
[expires_in] => 14769
)
========== BLOCKED Data ==========
Warning: file_get_contents(https://api.twitch.tv/helix/users/blocks?broadcaster_id=60799143&first=100): Failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized
in E:\xampp\htdocs\Twitch\auth.php on line 89
My code is…
echo "========== VALIDATION Data ==========\r\n";
$accesstoken = $authinfo["access_token"];
$expiry = $authinfo["expires_in"];
$idtoken = $authinfo["id_token"];
$refresh = $authinfo["refresh_token"];
$getinfo = "https://id.twitch.tv/oauth2/validate";
$context = stream_context_create(
array(
'http'=>array(
'method'=>"GET",
'header'=>"Authorization: OAuth $accesstoken"
)
)
);
$validinfo = file_get_contents($getinfo, false, $context);
$validinfo = json_decode($validinfo, true);
zprint($validinfo);
if (isset($validinfo["user_id"])) {
echo "========== BLOCKED Data ==========\r\n";
$userid = $validinfo["user_id"];
$username = $validinfo["login"];
$getinfo = "https://api.twitch.tv/helix/users/blocks" .
"?broadcaster_id=" . $userid .
"&first=100";
$context = stream_context_create(
array(
'http'=>array(
'method'=>"GET",
'header'=>"Authorization: OAuth $accesstoken"
)
)
);
$blocked = file_get_contents($getinfo, false, $context);
$blocked = json_decode($blocked, true);
zprint($blocked);
Many thanks
Zoe