We basically have a page here that pulls our players streams from the justin.tv api and displays them in order of highest viewers first. It requires just basic css/html/php to use proven by the fact I wrote it...
Does the following:
- Lists streams from twitch/justin.tv
- Gives online/offline status
- Gives viewer count
- Gives thumbnail image
- Gives bio (description)
- Styles it out like a badman
Its not finished yet as there is one problem I cant overcome - the fact that if multiple streams have the same amount of viewers no ordering is done. If the view has 0 viewers then it works alright, just anything above that creates an problem. There seems to be an issue with the switch logic but I'll keep working on it. Any ideas to fix it would be appreciated.
Here is a link to all the files we used in a .rar file.
Edit: Updated the .rar file with more comments and changed the links to pictures so that they work when in the same folder as the php. Also added <html> tags so that you can plug and go with it. (Hopefully, let me know if theres an error)
I will admit now - im a noob programmer so dont hate me because its a ridiculously long-winded way of doing it but if anyone has any other suggestions of how it can be implemented I would love to talk about it.
The two main files are streamlist_with_ordering.php and streamlist_no_order.php. The first one does the ordering but requires a lot more effort to add new users. The second just adds the streams. But they should give you an idea of how it works.
Note on installation: put the php code where you want the stream list to show (inside the html).
Instructions to add streams:
1. To add a new user simply copy and paste one of the sections at the top (e.g. the bit commented "Sirius api pull") and change the api and url link to your own member.
2. Change the variables to +1 (i.e. viewers4 to viewers5, etc) and add the new one to the thumbnail, description and viewers check below.
3. Add a new entry to the title validation which sets a default title if the stream is not on.
4. Copy and paste the <div class="stream_main"> and everything inside it and change the php variables to match your new entry.
5 - only if you want ordering. The ordering is the annoying to bit to change. I've tried to keep it as clear as possible but im not gonna lie, it looks scruffy as hell
Anyway to add a new user, first add the new $viewer5 to the $viewarray. Then add a new set of placeholders which should be simple to follow. Then in the first switch add a new case with the new $viewers variable as its condition. Then comes the fun part. You have to copy and paste the same structure (the second switch) as the previous cases but edit it to fit the new variable.
I cant really explain how to do this in less than 2000 words but you should be able to get it from the current code.
Finally you need to go through each second/nested switch and add a 5th case (case 4) and add the code to deal with the 5th set of variables.
Again apologies that its so long winded but its just to give people an idea of how it can be done. If I have time over the next few months I'll try and come up with a lot neater way to do it. Maybe a plugin of sorts.
If anyone wants to discuss this/get more information I can be found on IRC #MushroomMayhem @ Quakenet.
P.S. Ildjarn says: This works in Joomla if you download the plugin which allows php in articles.
Edited by Syipher, 17 April 2012 - 01:55 PM.