Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Hockey3.php

By: a guest on Nov 20th, 2013  |  syntax: PHP  |  size: 2.37 KB  |  views: 758  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <games>
  3. <?php
  4. date_default_timezone_set('America/New_York');
  5.         $sked = file_get_contents( 'http://live.nhl.com/GameData/SeasonSchedule-20132014.json' );
  6.         $sked_json = json_decode( $sked );
  7.         $todays_date = date( 'Ymd', time() );
  8.         $hour = date('H',time());
  9.         if ($hour < 3) { $todays_date = $todays_date - 1; }
  10.         $output = '';
  11.         $x=1;
  12.         foreach ( $sked_json as $game ) {
  13.                 $date = $game->est;
  14.                 $game_date = date( 'Ymd', strtotime( $date ) );
  15.                 if( $game_date != $todays_date ) {
  16.                         continue;
  17.                 }
  18.  
  19.                 $game_id = substr( $game->id, -4 );
  20.  
  21.                 $streams = file_get_contents( 'http://smb.cdnak.neulion.com/fs/nhl/mobile/feed_new/data/streams/2013/ipad/02_'.$game_id.'.json' );
  22.                 $streams_json = json_decode( $streams );
  23.                 $stream_a = $streams_json->gameStreams->ipad->away->live->bitrate0;
  24.                 $stream_h = $streams_json->gameStreams->ipad->home->live->bitrate0;
  25.                 if( !isset( $streams_json->gameStreams->ipad->away->live ) ) { $stream_a = "nil"; }
  26.                 if( !isset( $streams_json->gameStreams->ipad->home->live ) ) { $stream_h = "nil"; }
  27.  
  28.                 $output .= '<game internal_id="' . $x . '" game_id="' . $game_id . '" game_date="' . date("Y-m-d", time() ) . ' ' . date( 'g:i a', strtotime( $game->est) ) . '" season="1314">' . "\n";
  29.                 $x++;
  30.                 $output .= '<home_team>' . $game->h . '</home_team>' . "\n";
  31.                 $output .= '<away_team>' . $game->a . '</away_team>' . "\n";
  32.                 $output .= '<assignments>' . "\n";
  33.                 $output .= '<assignment internal_id="' . $x . '" feed_name="a" feed_display_name="away">' . "\n";
  34.                 $x++;
  35.                 $output .= '<ipad_url>' . $stream_a . '</ipad_url>' . "\n";
  36.                 $output .= '</assignment>' . "\n";
  37.                 $output .= '<assignment internal_id="' . $x . '" feed_name="h" feed_display_name="home">' . "\n";
  38.                 $x++;
  39.                 $output .= '<ipad_url>' . $stream_h . '</ipad_url>' . "\n";
  40.                 $output .= '</assignment>' . "\n";
  41.                 $output .= '</assignments>' . "\n";
  42.                 $output .= '</game>' . "\n";
  43.         }
  44.         echo $output;
  45. ?>
  46. </games>