New to api, It's 4am. Let me wake up to some understanding

Um, I am new to api… Wanting to show if streamers on a stream team are live on my site or even just a individual streamer. Clearly just testing my own account atm. Using a website I currently have to test on.

Thinking I need to get a OAuth token, below is as far as I got…

“object(stdClass)#4 (3) { [“error”]=> string(12) “Unauthorized” [“status”]=> int(401) [“message”]=> string(22) “OAuth token is missing” } lets see”

I mean I am game for really any kinda of PHP break down on how to get this done. Please be clear if I need to do something outside of PHP.

$ch = curl_init(‘https://api.twitch.tv/helix/streams?user_login=’);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Client-ID: ’
));

$data = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);

if ($info[‘http_code’] != “”) {
$data = json_decode($data);
var_dump($data);
} else {
echo 'Failed with ’ . $info[‘http_code’];
}
die(“lets see”);

Honestly even a ajax example would be awesome. Cause I could do a simple display if data eq …

fetch(
https://api.twitch.tv/kraken/videos/SOMEID’,
{
headers: {
‘client-id’: ‘SOMECLIENTID’,
‘accept’: ‘application/vnd.twitchtv.v5+json’
}
}
)
.then(resp => { return resp.json() })
.then(resp => { console.log(resp) })
.catch(err => { console.log(err) });

I’ve got this working, Just don’t know where to see if they are live. I get all their stream info just not data that screams this streamer is live to me.

If the stream info is present in the array, it means they are live, if they are not returned, they are not live.

Thank you, atm I was trying to use https://api.twitch.tv/kraken/channels instead of https://api.twitch.tv/kraken/streams.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.