# Integration of a live hosting on a website

**URL:** <https://discuss.dev.twitch.com/t/integration-of-a-live-hosting-on-a-website/25120>\
**Category:** API\
**Created:** [April 22, 2020, 3:46pm UTC](https://discuss.dev.twitch.com/t/integration-of-a-live-hosting-on-a-website/25120 "2020-04-22T15:46:25Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![PepeMax](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/pepemax/32/8423_2.png) [@PepeMax](https://discuss.dev.twitch.com/u/PepeMax)\
**Post date:** [April 22, 2020, 3:46pm UTC](https://discuss.dev.twitch.com/t/integration-of-a-live-hosting-on-a-website/25120/1 "2020-04-22T15:46:25Z")

</div>

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 😂.  
THANKS

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [April 22, 2020, 4:15pm UTC](https://discuss.dev.twitch.com/t/integration-of-a-live-hosting-on-a-website/25120/2 "2020-04-22T16:15:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![matt\_thomas](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/matt_thomas/32/710_2.png) [@matt\_thomas](https://discuss.dev.twitch.com/u/matt_thomas)\
**Post date:** [April 23, 2020, 3:34am UTC](https://discuss.dev.twitch.com/t/integration-of-a-live-hosting-on-a-website/25120/3 "2020-04-23T03:34:50Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![PepeMax](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/pepemax/32/8423_2.png) [@PepeMax](https://discuss.dev.twitch.com/u/PepeMax)\
**Post date:** [April 23, 2020, 11:03am UTC](https://discuss.dev.twitch.com/t/integration-of-a-live-hosting-on-a-website/25120/4 "2020-04-23T11:03:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [April 23, 2020, 11:04am UTC](https://discuss.dev.twitch.com/t/integration-of-a-live-hosting-on-a-website/25120/5 "2020-04-23T11:04:38Z")

</div>

> [@PepeMax](#):
>
> Do you know why embeded is not supported?

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.

---

<div class="post-metadata">

**Author:** ![PepeMax](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/pepemax/32/8423_2.png) [@PepeMax](https://discuss.dev.twitch.com/u/PepeMax)\
**Post date:** [April 23, 2020, 1:01pm UTC](https://discuss.dev.twitch.com/t/integration-of-a-live-hosting-on-a-website/25120/6 "2020-04-23T13:01:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [April 23, 2020, 1:32pm UTC](https://discuss.dev.twitch.com/t/integration-of-a-live-hosting-on-a-website/25120/7 "2020-04-23T13:32:45Z")

</div>

Modify the code to call this helix endpoint

> **[Reference](https://dev.twitch.tv/docs/api/reference/)**
>
> Twitch Developer tools and services to integrate Twitch into your development or create interactive experience on twitch.tv.

You can include up to 100 `user_login`s

> [https://api.twitch.tv/helix/streams?user\_login=firstperson&user\_login=secondperson](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.

---

<div class="post-metadata">

**Author:** ![PepeMax](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/pepemax/32/8423_2.png) [@PepeMax](https://discuss.dev.twitch.com/u/PepeMax)\
**Post date:** [April 23, 2020, 3:11pm UTC](https://discuss.dev.twitch.com/t/integration-of-a-live-hosting-on-a-website/25120/8 "2020-04-23T15:11:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![matt\_thomas](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/matt_thomas/32/710_2.png) [@matt\_thomas](https://discuss.dev.twitch.com/u/matt_thomas)\
**Post date:** [April 23, 2020, 5:25pm UTC](https://discuss.dev.twitch.com/t/integration-of-a-live-hosting-on-a-website/25120/9 "2020-04-23T17:25:42Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![PepeMax](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/pepemax/32/8423_2.png) [@PepeMax](https://discuss.dev.twitch.com/u/PepeMax)\
**Post date:** [April 24, 2020, 11:01am UTC](https://discuss.dev.twitch.com/t/integration-of-a-live-hosting-on-a-website/25120/10 "2020-04-24T11:01:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ArcticWolves](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/arcticwolves/32/8804_2.png) [@ArcticWolves](https://discuss.dev.twitch.com/u/ArcticWolves)\
**Post date:** [May 23, 2020, 6:53pm UTC](https://discuss.dev.twitch.com/t/integration-of-a-live-hosting-on-a-website/25120/11 "2020-05-23T18:53:10Z")

</div>

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/](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.com/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]
> 
> ```

---

<div class="post-metadata">

**Author:** ![matt\_thomas](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/matt_thomas/32/710_2.png) [@matt\_thomas](https://discuss.dev.twitch.com/u/matt_thomas)\
**Post date:** [May 23, 2020, 7:14pm UTC](https://discuss.dev.twitch.com/t/integration-of-a-live-hosting-on-a-website/25120/12 "2020-05-23T19:14:00Z")

</div>

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

 ![](https://d2opxh93rbxzdn.cloudfront.net/original/2X/d/d21b88d9a435dfef71941e4524cd46f79211b0e7.png)

---

<div class="post-metadata">

**Author:** ![ArcticWolves](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/arcticwolves/32/8804_2.png) [@ArcticWolves](https://discuss.dev.twitch.com/u/ArcticWolves)\
**Post date:** [May 23, 2020, 7:16pm UTC](https://discuss.dev.twitch.com/t/integration-of-a-live-hosting-on-a-website/25120/13 "2020-05-23T19:16:27Z")

</div>

I am a noob at HTML.

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

---

<div class="post-metadata">

**Author:** ![matt\_thomas](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/matt_thomas/32/710_2.png) [@matt\_thomas](https://discuss.dev.twitch.com/u/matt_thomas)\
**Post date:** [May 24, 2020, 3:03am UTC](https://discuss.dev.twitch.com/t/integration-of-a-live-hosting-on-a-website/25120/14 "2020-05-24T03:03:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://d2opxh93rbxzdn.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://discuss.dev.twitch.com/u/system)\
**Post date:** [June 23, 2020, 3:03am UTC](https://discuss.dev.twitch.com/t/integration-of-a-live-hosting-on-a-website/25120/15 "2020-06-23T03:03:44Z")

</div>

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