Twitch Block for IPB4

by Mr_Joker - 02-06-2015, 04:01 PM
YouR JuSt G4Y
Posts:
879
Joined:
Feb 2015
Likes:
32
Credits:
317
Reputation:
3
2 Years of Service
#1
OP
Posted: 02-06-2015, 04:01 PM (This post was last modified: 02-06-2015, 04:02 PM by Mr_Joker.)
You will need to create PHP block under Pages and use the following code.
Code:
function is_channel_live($channel)
{
$request = json_decode( @file_get_contents( 'https://api.twitch.tv/kraken/streams/' . $channel ) );
return ( ! is_null( $request->stream ) ) ? TRUE : FALSE;
}
$chan = "twitch";
if (is_channel_live($chan)==true)
echo "
<h3 class='ipsType_reset ipsWidget_title'>Live Stream (Online)</h3>
<div class='embed-container'>
<iframe src='http://www.twitch.tv/' . $chan . '/embed' frameborder='0'></iframe>
</div>"
;
 
else
echo "
<h3 class='ipsType_reset ipsWidget_title'>Live Stream (Offline)</h3>
<div class='embed-container'>
<font color=red><b>Offline</b></font>
</div>"
;
Newbie
Posts:
14
Joined:
May 2015
Likes:
0
Credits:
15
Reputation:
0
2 Years of Service
#2
Posted: 03-06-2015, 05:14 AM
wow~!
good tut~! thsnks Mr_Jocker
The last reply on this thread is older than a month. Please do not unnecessarily bump it.
Register an account or login to reply
Create an account
Create a free account today and start posting right away. It only takes a few seconds.
Login
Log into an existing account.
1 Guest(s)