Advice on combining two XML feeds together - own3d/twitch.tv

JoanL

New Member
I am working on a small project to display live streams for Dota 2, League of Legends and StarCraft 2 and was using a 3rd party hosted api that had both feeds from Twitch.tv and own3d - I couldn't of been happier, until they shut down their servers!I tried merging them together with Yahoo pipes but didn't have much luck!These are the two feeds I am working with:Twitch.tv/justin.tv - http://api.justin.tv/api/stream/list.xml?category=gaming&limit=15Own3d - http://api.own3d.tv/live?limit=15Here is my attempt at combining the two feeds, by just listing them on top of each other. Its a temporary solution but they are not sorted by live viewers (which is something I would like to do) - The current script I have:\[code\]<table class="table"><thead><tr><th colspan="4" class="streamheader">Current live Sstreams</th></tr></thead><tbody><?php$xmlFileData2 = file_get_contents("http://api.own3d.tv/live?limit=15");$xmlData2 = new SimpleXMLElement($xmlFileData2);foreach($xmlData2->channel->item as $item) if ($item->misc['game'] == 'Dota 2' OR $item->misc['game'] == 'League of Legends' OR $item->misc['game'] == 'StarCraft II') {{$titlelimit = $item->title;$title = substr($titlelimit,0,20);echo "<tr><td>";if ($item->misc['game'] == 'League of Legends')echo"<img src='http://localhost/ae/wp-content/themes/ae/img/lol.jpg' /></td><td>";elseif ($item->misc['game'] == 'StarCraft II')echo"<img src='http://localhost/ae/wp-content/themes/ae/img/sc2.jpg' /></td><td>";elseif ($item->misc['game'] == 'Dota 2')echo"<img src='http://localhost/ae/wp-content/themes/ae/img/dota2.jpg' /></td><td>";elseecho "none";echo "<a href='";$link = $item->link; $findthis ="/www.own3d.tv/live/"; $replacement ="ae/stream/"; echo str_replace ($findthis, $replacement, $link);echo "'>";echo $title;echo "</a></td><td>";$author = $item->author; $find ="/[email protected]/"; $replace =""; echo preg_replace ($find, $replace, $author);echo "<td>";echo $item->misc['viewers']; echo "</td> </tr>";}}else{echo "";}$xmlFileData1 = file_get_contents("http://api.justin.tv/api/stream/list.xml?category=gaming&limit=15");$xmlData1 = new SimpleXMLElement($xmlFileData1);foreach($xmlData1->stream as $itemtwitch) {$game = $itemtwitch->meta_game;$sc2 = "StarCraft II: Wings of Liberty";if ($itemtwitch->meta_game == 'Dota 2' OR $itemtwitch->meta_game == 'League of Legends' OR $itemtwitch->meta_game == 'StarCraft II: Wings of Liberty') {{echo "<tr><td>";$titlelimittwitch = $itemtwitch->title;$titlelimittwitch = substr($titlelimittwitch,0,20);if ($itemtwitch->meta_game == 'League of Legends')echo"<img src='http://localhost/ae/wp-content/themes/ae/img/lol.jpg' /></td><td>";elseif ($itemtwitch->meta_game == 'StarCraft II: Wings of Liberty')echo"<img src='http://localhost/ae/wp-content/themes/ae/img/sc2.jpg' /></td><td>";elseif ($itemtwitch->meta_game == 'Dota 2')echo"<img src='http://localhost/ae/wp-content/themes/ae/img/dota2.jpg' /></td><td>";elseecho "none";$data = http://stackoverflow.com/questions/11275735/$itemtwitch->name;$find ="/live_user_/";$replace ="";echo "<a href='";echo "http://localhost/ae/stream/";echo preg_replace ($find, $replace, $data);echo "''>";echo "$titlelimittwitch";//print(" - " . $itemtwitch->meta_game . "");echo "</a></td><td>";echo preg_replace ($find, $replace, $data);print("</td><td>" . $itemtwitch->channel_count . "</td></tr>");}}else {echo "";}}?><tr><th colspan="4" class="streamheader centered">View all streams</th></tr> </tbody></table>\[/code\]Any guidance or being pointed in the right direction would be fantastic.Cheers!
 
Back
Top