Go Back   vb.org Archive > vBulletin Modifications > vBulletin 4.x Modifications > vBulletin 4.x Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Show online/offline status for twitch users and embed channel via VbAdvanced Details »»
Show online/offline status for twitch users and embed channel via VbAdvanced
Version: 1.1, by OUTL4W OUTL4W is offline
Developer Last Online: Apr 2020 Show Printable Version Email this Page

Category: vBulletin Forum Sideblocks - Version: 4.2.1 Rating:
Released: 01-07-2014 Last Update: 09-15-2014 Installs: 8
Template Edits
Translations  
No support by the author.

Thought I would share this lil mod that will show if specific Twitch users are offline or online. This should work on all vb versions if using vbadvance. This will work with vbadvance and in the sidebar block of vb4...haven't tested in sidebar anywhere or Everywhere Sidebar mod's. For Sidebar blocks this will show whose online and when clicking link will either take you to their twitch channel or if using Vbadvance will take you to that page where channel is embedded.

1st upload folder within attached zip file to your root dir.

for sidebar in vb4x:
>acp>Forums & Moderators>forums blocks manager>add block>Custom HTML/PHP
click "continue"
Title: whatever you want
Cache time: 1
Display Order: your preference
Content Type: HTML

use this if you want to direct to Twitch.tv channel:
Content:
Code:
<a href="http://www.twitch.tv/channelname"><strong><span style="color: red;">Member name</span></strong></a> <img src="http://www.yourdomainname/status/twitch.php?stream=channelname">
<br>
if wanting to add more members simply copy & paste the code and change text in red to suit your needs.

Clicking link will direct user to Twitch.tv page to watch channel.
that's it....but if using DBTech Twitch TV integration then use this code:
Code:
<a href="http://www.yourdomainname.com/twitch.php"><strong><span style="color: red;">Member name</span></strong></a> <img src="http://www.yourdomainname/status/twitch.php?stream=channelname
<br>

but if using Vbadvance then continue....this is written as if you already have working knowledge of vbadvance and what to do once modules are created. If not I will do my best to answer any questions you might have.

use this if using vbadvance where channel will be embedded:
Content:
Code:
<a href="http://www.domainname/cmps_index.php?page=pagename"><strong><span style="color: #ff0000;">Member name</strong></span></a><img  src="http://www.domainname/status/twitch.php?stream=channelname"><p style="float:right;"></p>
<br>
Clicking link will direct user to vbadvance page to watch embedded channel.
and if wanting to add more members simply copy & paste the code and change text in red to suit your needs.

Embedding channel in Vbadvance:
acp>vBa CMPS>add module>[HTML Code Module]
Module Title: Member's Name
Active: yes
CSS Templates to Include: leave blank
Module Content:
Code:
<object type="application/x-shockwave-flash" id="live_embed_player_flash" data="http://www.twitch.tv/widgets/live_embed_player.swf?channel=channelname" bgcolor="#000000" height="335" width="375"><param name="allowFullScreen" value="true"><param name="allowScriptAccess" value="always"><param name="allowNetworking" value="all"><param name="movie" value="http://www.twitch.tv/widgets/live_embed_player.swf"><param name="flashvars" value="hostname=www.twitch.tv&channel=channelname&auto_play=true&start_volume=25"></object><iframe id="chat_embed" src="http://twitch.tv/chat/embed?channel=channelname&popout_chat=true" frameborder="0" height="335" scrolling="no" width="350"></iframe><br><br><div style="text-align: center;"><strong><span style="color: #c00000;"><a href="http://www.twitch.tv/channelname">FOLLOW ME</a></span></strong></div>
Use Module Wrapper Template: yes
Alternative Module Wrapper Template: Leave blank
Module Link: Leave blank
Title Row Colspan: 0
Form Code: Leave blank
Wrap a Table Around Content: no
Collapse Module by Default: yes
Usergroup Permissions:
click the usergroups you wish to have access to this module.

if not wanting to include chat window then delete blue text and enlarge the height & width of video window to your preference. This will also add a link below the video window to goto member's channel and click the "follow button".

While on Vbadvance page where channels are embedded...if you want to add a module showing whose online/offline since all the embedded module's will be collapsed by default, if not all the channels will auto-play. So by keeping them collapsed and adding a module showing whose online will streamline the process:

if wanting to also have a module on the Vbadvance page where channels are embedded:
acp>vBa CMPS>add module>[HTML Code Module]
Module Title: Streams Online/Offline
Active: yes
CSS Templates to Include: leave blank
Module Content:
Code:
<a href="http://www.twitch.tv/channelname"><strong><span style="color: red;">Member name</span></strong></a> <img src="http://www.yourdomainname/status/twitch.php?stream=channelname">
<br>
Use Module Wrapper Template: yes
Alternative Module Wrapper Template: Leave blank
Module Link: Leave blank
Title Row Colspan: 0
Form Code: Leave blank
Wrap a Table Around Content: no
Collapse Module by Default: no
Usergroup Permissions:
click the usergroups you wish to have access to this module.

example here for Vbadvanced page. (Twitcher's)
example here for VB4 sideblock in the sidebar.(Live Stream's)
Please Mark as Installed and thank you.....


09/16/2014: update 1.1
since the link is dead to justin.TV, updated the twitch.php file with the info from post#7 thanks @Dave

If you want to show a stream status in member's postbit (legacy) then you'll need to do a template change....
vb3x:
find
Code:
if condition="$post['age']"><div>$vbphrase[age]: $post[age]</div></if>
				<div>
add after or where ever you like:
Code:
<!-- stream status -->
<div style="color:yourchoice; font-weight: bold;">
<if condition="$post['fieldx']">Stream:<a href="http://www.twitch.tv/$post[fieldx]" target="_blank"><img src="http://www.your_domain_name.com/status/twitch.php?stream=$post[fieldx]"></a></if>
</div>
<!-- end stream status -->
__________________________________________________ ____________________________________
vb4x
find:
Code:
<vb:if condition="$post['age']"><dt>{vb:rawphrase age}</dt> <dd>{vb:raw post.age}</dd></vb:if>
add after or where ever you like:
Code:
<!-- stream status -->
<div style="color:yourchoice; font-weight: bold;">
<vb:if condition="$post['fieldx']">Stream:<a href="http://www.twitch.tv/$post[fieldx]" target="_blank"><img src="http://www.your_domain_name.com/status/twitch.php?stream={vb:raw post.fieldx}"></a></vb:if>
</div>
<!-- end stream status -->

then when user is online....you will be able to click "online" and will take you to their channel.

Download Now

File Type: zip status.zip (7.7 KB, 38 views)
File Type: zip status_1.1.zip (7.7 KB, 35 views)

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.
Благодарность от:
Tibiaspy

Comments
  #2  
Old 05-03-2014, 04:41 PM
r00028304 r00028304 is offline
 
Join Date: Aug 2010
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for this!

Is there anyway to capture the teams playing into the stream name directly from twitch like TeamLiquid has?
Reply With Quote
  #3  
Old 09-11-2014, 12:08 PM
Tibiaspy Tibiaspy is offline
 
Join Date: May 2008
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This mod is no longer working. Probably because it uses http://api.justin.tv and it's dead now. Dev would have to change it to work with twitch API. I tried that but I failed
Reply With Quote
  #4  
Old 09-11-2014, 01:27 PM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Tibiaspy View Post
This mod is no longer working. Probably because it uses http://api.justin.tv and it's dead now. Dev would have to change it to work with twitch API. I tried that but I failed
Here, this should work. Just replace the code of the old file with the code beneath, works exactly the same.

PHP Code:
<?php  
    $json_array 
json_decode(@curl("https://api.twitch.tv/channels/" $_GET['stream']), true);
    
    if(
$json_array['game'] != NULL && $json_array['status'] != NULL){
        echo 
file_get_contents("online.png");
    }else{
        echo 
file_get_contents("offline.png");
    }

    function 
curl($url$post null$retries 3){
        
$curl curl_init($url);

        if(
is_resource($curl) === true){
                
curl_setopt($curlCURLOPT_FAILONERRORtrue);
                
curl_setopt($curlCURLOPT_FOLLOWLOCATIONtrue);
                
curl_setopt($curlCURLOPT_RETURNTRANSFERtrue);
                
curl_setopt($curlCURLOPT_SSL_VERIFYHOSTfalse);
                
curl_setopt($curlCURLOPT_SSL_VERIFYPEERfalse);

                if(isset(
$post) === true){
                        
curl_setopt($curlCURLOPT_POSTtrue);
                        
curl_setopt($curlCURLOPT_POSTFIELDS, (is_array($post) === true) ? http_build_query($post"""&"): $post);
                }

                
$result false;

                while((
$result === false) && (--$retries 0)){
                        
$result curl_exec($curl);
                }

                
curl_close($curl);
        }
        return 
$result;

}

?>
Reply With Quote
  #5  
Old 09-11-2014, 03:38 PM
OUTL4W OUTL4W is offline
 
Join Date: May 2013
Location: Gettysburg, Pa
Posts: 130
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dave View Post
Here, this should work. Just replace the code of the old file with the code beneath, works exactly the same.

PHP Code:
<?php  
    $json_array 
json_decode(@curl("https://api.twitch.tv/channels/" $_GET['stream']), true);
    
    if(
$json_array['game'] != NULL && $json_array['status'] != NULL){
        echo 
file_get_contents("online.png");
    }else{
        echo 
file_get_contents("offline.png");
    }

    function 
curl($url$post null$retries 3){
        
$curl curl_init($url);

        if(
is_resource($curl) === true){
                
curl_setopt($curlCURLOPT_FAILONERRORtrue);
                
curl_setopt($curlCURLOPT_FOLLOWLOCATIONtrue);
                
curl_setopt($curlCURLOPT_RETURNTRANSFERtrue);
                
curl_setopt($curlCURLOPT_SSL_VERIFYHOSTfalse);
                
curl_setopt($curlCURLOPT_SSL_VERIFYPEERfalse);

                if(isset(
$post) === true){
                        
curl_setopt($curlCURLOPT_POSTtrue);
                        
curl_setopt($curlCURLOPT_POSTFIELDS, (is_array($post) === true) ? http_build_query($post"""&"): $post);
                }

                
$result false;

                while((
$result === false) && (--$retries 0)){
                        
$result curl_exec($curl);
                }

                
curl_close($curl);
        }
        return 
$result;

}

?>
tried testing this...but shows EVERYONE in my list as being on line...even me.
Reply With Quote
  #6  
Old 09-11-2014, 03:53 PM
hoangserip's Avatar
hoangserip hoangserip is offline
 
Join Date: Jun 2009
Posts: 101
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks... testing now.
Reply With Quote
  #7  
Old 09-11-2014, 07:02 PM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This should work. Else, well... I guess I'm being an idiot.

PHP Code:
<?php   
    $json_array 
json_decode(@curl("https://api.twitch.tv/kraken/streams/" $_GET['stream']), true);
     
    if(
$json_array['stream'] != NULL && isset($json_array['stream']['_id'])){ 
        echo 
file_get_contents("online.png"); 
    }else{ 
        echo 
file_get_contents("offline.png"); 
    } 

    function 
curl($url$post null$retries 3){ 
        
$curl curl_init($url); 

        if(
is_resource($curl) === true){ 
                
curl_setopt($curlCURLOPT_FAILONERRORtrue); 
                
curl_setopt($curlCURLOPT_FOLLOWLOCATIONtrue); 
                
curl_setopt($curlCURLOPT_RETURNTRANSFERtrue); 
                
curl_setopt($curlCURLOPT_SSL_VERIFYHOSTfalse); 
                
curl_setopt($curlCURLOPT_SSL_VERIFYPEERfalse); 

                if(isset(
$post) === true){ 
                        
curl_setopt($curlCURLOPT_POSTtrue); 
                        
curl_setopt($curlCURLOPT_POSTFIELDS, (is_array($post) === true) ? http_build_query($post"""&"): $post);
                } 

                
$result false

                while((
$result === false) && (--$retries 0)){ 
                        
$result curl_exec($curl); 
                } 

                
curl_close($curl); 
        } 
        return 
$result



?>
Reply With Quote
2 благодарности(ей) от:
OUTL4W, Tibiaspy
  #8  
Old 09-12-2014, 06:51 PM
Tibiaspy Tibiaspy is offline
 
Join Date: May 2008
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dave View Post
This should work. Else, well... I guess I'm being an idiot.
It works! Thanks mate!
Reply With Quote
  #9  
Old 09-16-2014, 12:57 PM
OUTL4W OUTL4W is offline
 
Join Date: May 2013
Location: Gettysburg, Pa
Posts: 130
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

updated 1.1
Reply With Quote
  #10  
Old 03-27-2015, 12:44 PM
OUTL4W OUTL4W is offline
 
Join Date: May 2013
Location: Gettysburg, Pa
Posts: 130
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dave View Post
This should work. Else, well... I guess I'm being an idiot.

PHP Code:
<?php   
    $json_array 
json_decode(@curl("https://api.twitch.tv/kraken/streams/" $_GET['stream']), true);
     
    if(
$json_array['stream'] != NULL && isset($json_array['stream']['_id'])){ 
        echo 
file_get_contents("online.png"); 
    }else{ 
        echo 
file_get_contents("offline.png"); 
    } 

    function 
curl($url$post null$retries 3){ 
        
$curl curl_init($url); 

        if(
is_resource($curl) === true){ 
                
curl_setopt($curlCURLOPT_FAILONERRORtrue); 
                
curl_setopt($curlCURLOPT_FOLLOWLOCATIONtrue); 
                
curl_setopt($curlCURLOPT_RETURNTRANSFERtrue); 
                
curl_setopt($curlCURLOPT_SSL_VERIFYHOSTfalse); 
                
curl_setopt($curlCURLOPT_SSL_VERIFYPEERfalse); 

                if(isset(
$post) === true){ 
                        
curl_setopt($curlCURLOPT_POSTtrue); 
                        
curl_setopt($curlCURLOPT_POSTFIELDS, (is_array($post) === true) ? http_build_query($post"""&"): $post);
                } 

                
$result false

                while((
$result === false) && (--$retries 0)){ 
                        
$result curl_exec($curl); 
                } 

                
curl_close($curl); 
        } 
        return 
$result



?>
again thank you...
I have this setup in a fixed slide-out tab via css that pulls out when hovering over it...what I was wondering is there any way to pull notifications off the above php script? I'm guessing some javascript is required in order to call the css class name to show the notification but clueless about javascript.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:50 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04693 seconds
  • Memory Usage 2,434KB
  • Queries Executed 24 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (9)bbcode_code
  • (4)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (3)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (2)postbit_attachment
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete