Am I even doing this right...? (is_live integration into my own site)

Ok! did that, now I am down to: Token OKArray ( [data] => Array ( ) [pagination] => Array ( ) ) darkmage4 is not live

Also, checking out your github now, got a lot of useful information! But yeah, stack overflow is mainly where I am usually at. Otherwise, the only time I am on github is for my MC server to report issues to the devs.

And the echo for tokenOK
You left in a print_r($profile_data);
So you probably left in some of the debugs in the token create

A lot of this script is built around it being CRON executed rahter than web executed. So it’s noisy on the loggging

Ok, now that I can reply now. Everything is working! The only thing that isn’t working is the $game_name and $is_live so for the live or offline part. I just put is live, and is offline.

But the game name is blank. If I switch it to ID. It will show Twitch’s game ID number system. But to visitors that might be confusing to them as to me playing numbers. Lol.

Otherwise, everything else outputs great. Thanks for the help!

Theres no $game_name in your code setting the value

You need a

$game_name = $profile_data["data"][0]["game_name"];

Ok cool! Thanks. I’ll get to that as soon as I get home.

I forgot to add. But the static image of the thumbnail of the stream. Would that be separate from this code? I’d like to have it under the title of the stream. So basically it’s showing the thumbnail cropped in of what twitch decides the thumbnail to be. I know it’s the static image. Do I replace replace seagull with my name? Or how does that work?

Pull thumbnail_url from the response and substitute {width} and {height} for the size you want

Yeah, I put it in like it shows on the reference, but with the $thumbnail_url like this:

$thumbnail_url = “https://static-cdn.jtvnw.net/previews-ttv/live_user_darkmage4-{500}x{100}.jpg”;
At least with this one, it shows the image URL, but if I try <" img image.jpg > It breaks everything.

But obviously that doesn’t work… I also tried: $thumbnail_url = $profile_data[“data”][0][“thumbnail_url” “https://static-cdn.jtvnw.net/previews-ttv/live_user_darkmage4-{500}x{100}.jpg”];

But also with no luck, it just breaks the css of my site.

Remove the {}

so

https://static-cdn.jtvnw.net/previews-ttv/live_user_darkmage4-500x100.jpg

removed that and It’s not showing the image itself.
For example:

darkmage4 is Live! Game: GAME | Stream Time: 3 hours 26 Minutes | Viewers: views | TITLE: some title
https://-- static-cdn.jtvnw.net/previews-ttv/live_user_darkmage4-500x100--.jpg

I’m using a friends stream to reference everything, with their permission of course. but changed everything to mine when posting here of course.

it can’t show an image if you are offline.

https://api.twitch.tv/helix/streams?user_login=darkmage4

reports there is no live stream

I can’t help you when giving false data!

if I look up cohh

https://api.twitch.tv/helix/streams?user_login=cohhcarnage

Returns

{
"data": [
{
"id": "42165023900",
"user_id": "26610234",
"user_login": "cohhcarnage",
"user_name": "CohhCarnage",
"game_id": "512980",
"game_name": "Fall Guys: Ultimate Knockout",
"type": "live",
"title": "[!FinalWeek] Beer & Trip Dudes - Biomutant TOMORROW at 8am ET! - !VODChat - !Bike - #EpicPartner Creator Code: Cohh",
"viewer_count": 6220,
"started_at": "2021-05-24T22:26:42Z",
"language": "en",
"thumbnail_url": "https://static-cdn.jtvnw.net/previews-ttv/live_user_cohhcarnage-{width}x{height}.jpg",
"tag_ids": [
"6ea6bca4-4712-4ab9-a906-e3336a9d8039",
"96b6073f-450d-4248-8ed4-988e28f3f759",
"eaba0ad7-c4e1-4878-b37f-01308dbb65c8"
],
"is_mature": false
}
],
"pagination": {}
}

And

https://static-cdn.jtvnw.net/previews-ttv/live_user_cohhcarnage-{width}x{height}.jpg

becomes

https://static-cdn.jtvnw.net/previews-ttv/live_user_cohhcarnage-192x108.jpg

This is what I get

$thumbnail_url = "https://static-cdn.jtvnw.net/previews-ttv/live_user_martyseppy1552-500x100.jpg";

Looks like you forgot to use an HTML img tag

Yeah, I tried that. It broke the entire CSS. I tried that in the normal HTML, which i figured wouldn’t work. then I tried $thumbnail_url < img image.jpg > and still didn’t work. in the first echo line.

Not sure what you are doing since the only thing I have to work with is your PHP script.

And image tag is

<img src="theurl" /> btw not just <img theurl>

I have no idea what I am doing. lol. This is just way to confusing to me. I’m really really trying though. So I do apologize… I’ve been working on this single page for 30 hours the past 3 days and I’m just so tired of doing it. lol.
This is how I have it setup. I also tried the img line in the first line too. It just broke the rest of my site, so I had to remove that line. This is the only one that does not break my entire bottom half of the site where it just doesn’t show up.

echo "
$user is Live! Game: $game_name | Stream Time: $hours hours $minutes Minutes | Viewers: $viewer_count | TITLE: $title <br /> <img src="$thumbnail_url />";
} else {
echo "
$user is not live...";
}
?>
echo "
$user is Live! Game: $game_name | Stream Time: $hours hours $minutes Minutes | Viewers: $viewer_count | TITLE: $title <br /> <img src=\"$thumbnail_url\" />";
} else {
echo "
$user is not live...";
}

This is what it’s giving me when I do that. https://darkmage4.com/dm4/twitch.php

and this is what comes out of it:

martyseppy1552 is Live! Game: World of Warcraft | Stream Time: 0 hours 55 Minutes | Viewers: 1 | TITLE: Its another multi game night! !alsf <br /> <img src="https://static-cdn.jtvnw.net/previews-ttv/live_user_martyseppy1552-500x100.jpg" />

Seems correct. Other than your wacky dimensions.

Gotta love coding. It was the dimensions… I didn’t think it would be the dimensions. But its showing now… lol. Something so simple has to not work. lol. Thank you! I think I am all good now! Definitely need to figure out a good dimension when I recode my site to work around this.

Thank you! Don’t think I need anymore help, and I greatly appreciate everything!

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