Hello, I wanted to make a live / offline stream for the site.
to get the token I use the following code
<?php
$url = 'https://id.twitch.tv/oauth2/token?client_id=xxx&client_secret=xxx&grant_type=client_credentials';
if( $curl = curl_init() ) {
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_POST, true);
$out = curl_exec($curl);
$data= json_decode ($out, true);
$access_token = $data['access_token'];
echo $access_token;
curl_close($curl);
}
$ch = curl_init('https://api.twitch.tv/helix/streams?user_login=xxxxxx');
$options = array(
CURLOPT_HEADER => false,
CURLOPT_HTTPHEADER => array("Client-ID: xxxxxx"),
CURLOPT_HTTPHEADER => array("Authorization: Bearer xxxxxx"),
);
curl_setopt_array($ch, $options);
curl_exec($ch);
curl_close($ch);
But it doesn’t work
{“error”: “Unauthorized”, “status”: 401, “message”: “Client ID and OAuth token do not match”}
I tried and just insert token and also do via variable $access_token.
P.S. Sorry my english