Integration of a live hosting on a website

Good morning all,
Sorry for my English I am a young French.
I work on a website of a multi-gaming team, they want a page with a live from a twitch chain that hosts other twitch accounts.
I use WordPress, and I tried by an extension or with an <“iframe”> but when I live in host, it does not work whereas if I live from my PC with OBS for example it works.
Do you have a PHP or html idea to solve this. On the other hand I don’t know enough PHP yet so I will have to explain myself :joy:.
THANKS

The embed doesn’t support showing hosts. You’ll have to devise your own way of displaying hosts

If you wanted to just make a player the shows the team member with the most viewers at the moment, I made something for this a while back. It will need work and probably some updating (update the iframe/player for the latest documentation) for helix (currently using v5) but I think it can get you started: http://twitch.apiexampl.es/teams.php.txt

Also, on wordpress I would use a plugin like “XYZ HTML Snippets” to insert code blocks of php.

Thank you guys
Do you know why embeded is not supported? Just to find out
Thanks again to you guys.

The embed is a representation of your channels stream.

Your channel is not live as it’s hosting someone else, so there is no live stream from your channel to show.

Okay thank you
@matt_thomas I’ve tested your PHP script, it’s very good but do you have one that allows you to put a list of players and not a team because w"e can’t create a team yet.
Thanks to you

Modify the code to call this helix endpoint

You can include up to 100 user_logins

https://api.twitch.tv/helix/streams?user_login=firstperson&user_login=secondperson

process the JSON response for streams that are returned and sort/shuffle how you want and then display a record.

So a big thank you to you @BarryCarlyon, but I’m a great beginner in coding, I managed for example to add the cat.
But I can’t modify the code, it’s much too complex for me, I know a developer should try but I’m only discovering PHP so could someone please provide me with the code.
Thanks

I did a dirty setup but I think it is working and should show you a way to accomplish your goal. For a large production site you should most definitely build in some sort of caching.

http://twitch.apiexampl.es/pepemax.php.txt

The example has my client ID in it, I will be revoking it in a few days, so make sure you setup your own.

Thank you for this code.
There’s not going to be 1,000,000 people every day either :joy:.Thank you very much. That’s exactly what I was looking for.

I hope it is okay that I reply on this topic instead of a new one.
I want to do the same thing as PepeMax and display it on our dashboard. We basically have a Twitch Casting Team which should be displayed on the front page of us if they stream. Because the embedding does not show the host, we used the code of matt_thomas. I tried everything but it just doesn’t want to work. It doesn’t show a box and no active hosts. Anyone able to help?

It should be displayed here under our banner -> https://arctic-wolves.org/
we added the clientID and the streamers in the code but as you see, on our website it says only “Streamer:” and shows no streaming box, nothing.

Code:

Summary
[html]

<html>

<head>

<title>TEST</title>

</head>

<body>

<?php

/* Mucked together by Matt_Thomas @ Twitch.tv

revised version of http://twitch.apiexampl.es/teams.php.txt - designed for a group of streamers who are not a team yet, can manually create a list below..

created for PepeMax on https://discuss.dev.twitch.tv/t/integration-of-a-live-hosting-on-a-website/25120/8

Needs some sort of cachine for production use.

matt AT isso DOT pro */



/* file_get_contents replaced with curl function */

function file_get_contents_curl($url)

{

$curlHeader = array("Client-ID: id1ba10gzooqcd0gp31t9nhh3gd6pc", "Accept: application/vnd.twitchtv.v5+json"); /* SET CLIENT ID HERE */



$ch = curl_init();

curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);

curl_setopt($ch, CURLOPT_HEADER, 0);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);

curl_setopt($ch, CURLOPT_HTTPHEADER, $curlHeader);



$data = curl_exec($ch);

curl_close($ch);



return $data;

}

$channels = array("b1kaygaming", "foosel20_de"); /* For now, we use a manually set list of streamers */

$team = implode("&login=",$channels); /* Clean our list for next step */

$teamData = json_decode(@file_get_contents_curl('https://api.twitch.tv/helix/users?login=' . $team), true);

$teamMembersID = array();

if ($teamData['data'] != null) { /* Make sure we get a response from the API */

foreach ($teamData['data'] as $mydata) { /* Build an array with online streamers from our list */

if ($mydata['id'] != null) { /* Make sure the streamer has data in the API */

array_push($teamMembersID, $mydata['id']); /* Store the IDs */

}

}

$callAPI = implode(",", $teamMembersID); /* Clean our list for next step */

$dataArray = json_decode(@file_get_contents_curl('https://api.twitch.tv/kraken/streams?limit=1&channel=' . $callAPI), true); /* Take the auto populated team list and pick the top streamer */

$name = $dataArray['streams']['0']['channel']['name'];



} else { /* None of the $channels I wanted are avaiable now, so fetch the most popular one */

$backupArray = json_decode(@file_get_contents_curl('https://api.twitch.tv/kraken/streams?limit=1' . $callAPI), true);

if ($backupArray != null) {

foreach ($backupArray['streams'] as $mydata) {

if ($mydata['_id'] != null) {

$name = $mydata['channel']['display_name'];

$viewers = $mydata['viewers'];

} else {

echo "Error in results from api.twitch.tv, cannot fetch a channel."; /* API responded but not with expected data */

}

}

} else {

echo "Error in results from api.twitch.tv, probably cannot connect to server."; /* API probably did not respond at all */

}

}

?>

<center>

<h1> Streamer: <?php echo "$name"; ?> </h1>



<iframe src="http://player.twitch.tv/?channel=<?php echo "$name"; ?>" height="720" width="1280" frameborder="0" scrolling="no" allowfullscreen="true"></iframe>



</center>

</body>

</html>

[/html]

Looking at your page the entire php snippet is commented out.

I am a noob at HTML.

So you mean the code is not applied correctly and is not integrated?

As it is, it’s just text. It’s not being executed.

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