Advertisement
bashtech

Untitled

Aug 21st, 2014
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $channelname = file_get_contents('streamers.txt');
  3. $channelname = strtolower($channelname);
  4. echo $channelname;
  5. $clientId = "myid";
  6.  
  7. //**************************
  8. $remote_api_contents = file_get_contents('https://api.twitch.tv/kraken/streams?channel='.$channelname); //Client ID shouldn't be pasted as a URL param anymore, for now just exclude it
  9. var_dump($remote_api_contents ); //Lets see if the API is returning anything
  10.  
  11. $json_array = json_decode($remote_api_contents, true); //Decode the JSON
  12. var_dump($json_array); //Dump the decoded data
  13. //*************************
  14.  
  15. $channelTitle = $json_array['streams'];
  16. $result = count($json_array['streams']);
  17.  
  18.  
  19. $random = mt_rand(0,$result+1);
  20. $playthis = $json_array['streams'][$random]['channel']['name'];
  21. $display_name = $json_array['streams'][$random]['channel']['display_name'];
  22.  
  23. echo "<object type='application/x-shockwave-flash'
  24.        height='440'
  25.        width='720'
  26.        id='live_embed_player_flash'
  27.        data=\"http://www.twitch.tv/widgets/live_embed_player.swf?channel=$playthis\"
  28.        bgcolor='#000000'>
  29.  <param  name='allowFullScreen'
  30.          value='true' />
  31.  <param  name='allowScriptAccess'
  32.          value='always' />
  33.  <param  name='allowNetworking'
  34.          value='all' />
  35.  <param  name='movie'
  36.          value='http://www.twitch.tv/widgets/live_embed_player.swf' />
  37.  <param  name='flashvars'
  38.          value='hostname=www.twitch.tv&channel=$playthis&auto_play=true&start_volume=25' />
  39. </object>";
  40.  
  41. echo "\nStreamer: <a href = 'http://www.twitch.tv/$playthis' target = \"_new\">$display_name</a>";
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement