View Full Version : users in chat, confusing API
Chadi
12-23-2007, 11:22 PM
I installed and integrated Real Chat into my vbulletin forum. However, I wish to display on the forumhome (custom location and WOL area) how many members are in live chat and what room (if easily done).
I'm just not understanding this api doc at all and hope someone can help me out here.
http://www.realchat.com/doc/scripting-api.html
Thanks in advance.
Chadi
12-26-2007, 07:52 PM
I'm willing to pay $100 for someone to figure this out. Thanks.
MoT3rror
12-26-2007, 08:24 PM
Make a plugin with these options
Hook Location: forumhome_start
Title: API chat on forumhome(whatever you want to call this plugin it doesn't matter)
Execution order: 1
Plugin PHP Code:
function getAPI($command) {
$er = error_reporting(0);
$result = file_get_contents("http://chathost:controlport/?api.".$command);
//Replace http://chathost:controlport with the link to the your api chat
error_reporting($er);
return $result;
}
$apichat['currentuserslocation'] = getAPI("whowhere");
Plugin is Active: Yes
Remember to replace http://chathost:controlport with the link to the your api chat or this will not work. I suggest trying this on a test board before you put it on your main site to make sure it works. I suggest creating a new product by Plugins & Products -> Manage Product -> Add New Product. Then add the plugin to the product you created.
Then you can put $apichat[currentuserlocation] in your FORUMHOME template.
Chadi
12-26-2007, 09:04 PM
Thanks for the help, but its not working.
I tried this:
function getAPI($command) {
$er = error_reporting(0);
$result = file_get_contents("http://147.202.66.3:8085/?api.".$command);
//Replace http://chathost:controlport with the link to the your api chat
error_reporting($er);
return $result;
}
$apichat['currentuserslocation'] = getAPI("whowhere");
I also tried it with this link:
http://147.202.66.3:8085/?0,0,0,0,0
I did enable / activate plugin too.
ragtek
12-26-2007, 09:09 PM
The Scripting API commands allow you to retrieve information from your RealChat Server. For example, you can show your visitors who is online from a cutsom ASP or PHP page, before they enter the chat room.
API commands are served by the built-in Control Center HTTP server and are accessible from trusted IPs only.
check if the ip is allowed
Chadi
12-26-2007, 09:10 PM
Yes, because it shows it directly this way:
http://147.202.66.3:8085/?api.UserCount
0 is correct
But I cannot get the plugin setup right to display usercount in forumhome
--------------- Added 1198710896 at 1198710896 ---------------
Tried this also, won't work
function getAPI($command) {
$er = error_reporting(0);
$result = file_get_contents("http://147.202.66.3:8085/?api.".$command);
error_reporting($er);
return $result;
}
$apichat['currentuserslocation'] = getAPI("usercount");
ragtek
12-26-2007, 09:16 PM
make a php file and put the plugin code into it
function getAPI($command) {
$er = error_reporting(0);
$result = file_get_contents("http://147.202.66.3:8085/?api.".$command);
error_reporting($er);
return $result;
}
echo "Number of users: ".getAPI("UserCount")."<br/>";
echo "Rooms available: ".getAPI("RoomList");
and call the file from your browser
Because i'm getting an error if i want to try file_get_contents() from your ip, and if i call it direct http://147.202.66.3:8085/?api.UserCount i'm gettin the message that its forbidden
Chadi
12-26-2007, 09:19 PM
<a href="http://talkjesus.com/rcplugin.php" target="_blank">http://talkjesus.com/rcplugin.php</a>
Shows code only
ragtek
12-26-2007, 09:23 PM
with <? around, sorry
here's my try: www.ragtek.org/sandbox/chat.php
my server isn't allowed to get the info
also my clientpc isn't allowed when i click the link;)
Chadi
12-26-2007, 09:38 PM
Ok now it works via that link but not forumhome
MoT3rror
12-26-2007, 10:06 PM
Have you put $apichat[currentuserlocation] in the place where you want the number of users currently in chat in your FORUMHOME template to show on your page.
Chadi
12-26-2007, 10:12 PM
Yes I have. It should appear on right side of shout box above 4 icons, in the blank small purple box next to "members currently in live chat".
Tried this code also
function getAPI($command) {
$er = error_reporting(0);
$result = file_get_contents("http://147.202.66.3:8085/?api.".$command);
error_reporting($er);
return $result;
}
$apichat['currentuserslocation'] = getAPI("UserCount");
--------------- Added 1198714951 at 1198714951 ---------------
I also corrected the missing "s" in what you told me to put in forumhome template
currentuserslocation
That still didn't fix it.
MoT3rror
12-26-2007, 10:23 PM
Does this page (http://www.talkjesus.com/rcplugin.php) have this code
function getAPI($command) {
$er = error_reporting(0);
$result = file_get_contents("http://147.202.66.3:8085/?api.".$command);
error_reporting($er);
return $result;
}
echo "Number of users: ".getAPI("UserCount")."<br/>";
echo "Rooms available: ".getAPI("RoomList");
If it does, check to makesure your ip is allowed to access this page (http://147.202.66.3:8085/?api.Usercount) because it is not showing 0 or anything for me after Number of Users and Rooms available. This IP needs to be the IP address of your webserver.
Chadi
12-26-2007, 10:29 PM
That's because Usercount is supposed to be UserCount (case sensitive)
http://147.202.66.3:8085/?api.UserCount
The exact code in that rcplugin.php page is this:
<?php
function getAPI($command) {
$er = error_reporting(0);
$result = file_get_contents("http://147.202.66.3:8085/?api.".$command);
error_reporting($er);
return $result;
}
echo "Number of users: ".getAPI("UserCount")."<br/>";
echo "Rooms available: ".getAPI("RoomList");
?>
ragtek
12-26-2007, 10:33 PM
yes
but the problem is because of the ip
We are not allowed to view it
Chadi
12-26-2007, 10:38 PM
http://talkjesus.com:8085/?api.UserCount
It shows "1" properly, since I'm in chat.
However, still not showing up on forumhome :(
MoT3rror
12-26-2007, 10:38 PM
Yes but the problem is this page (http://www.talkjesus.com/rcplugin.php) is still outputting
Number of users:
Rooms available:
with no numbers. So the problem is the connection between your webserver and the API Chat getting the data(numbers).
Chadi
12-26-2007, 10:43 PM
Ok fixed! :) Thanks for all the help folks.
Actually, maybe you can help me get this in WOL area, a new section that is (kind of like FlashChat WOL's area) where it shows you the usernames in chat and if you hover, what room they're in.
I fixed the problem by adding the IP address to trusted IP in RC admin panel
i used this in forumhome
$apichat[currentuserlocation]
And this in plugin:
function getAPI($command) {
$er = error_reporting(0);
$result = file_get_contents("http://talkjesus.com:8085/?api.".$command);
error_reporting($er);
return $result;
}
$apichat['currentuserlocation'] = getAPI("UserCount");
MoT3rror
12-26-2007, 10:54 PM
Well you can use this but it is not going to do what you are talking about.
WhoWhere - lists all of the users in all rooms; with one room per line, formatted as: roomID: roomName: userList.
Insert this code at the end of the plugin.
$apichat['current_users'] = getAPI("WhoWhere");
That will get you the list of users and the room. What you are talking about would take some changes in how the API Chat works or some trial and error with PHP.
Chadi
12-26-2007, 10:57 PM
Thanks, but how do I get it to appear in the WOL section (footer)?
MoT3rror
12-26-2007, 10:59 PM
The template WHOSONLINE. You can just use the same variable. $apichat[currentuserlocation]
Chadi
12-26-2007, 11:08 PM
Wow, that template is really confusing me
$stylevar[htmldoctype]
<html xmlns="http://www.w3.org/1999/xhtml" dir="$stylevar[textdirection]" lang="$stylevar[languagecode]" xml:lang="$stylevar[languagecode]">
<head>
$headinclude
$metarefresh
<title>$vboptions[bbtitle] - $vbphrase[whos_online]</title>
</head>
<body>
$header
$navbar
<if condition="$pagenav">
<table cellpadding="0" cellspacing="0" border="0" width="100%" style="margin-bottom:3px">
<tr valign="bottom">
<td align="$stylevar[right]">$pagenav</td>
</tr>
</table>
</if>
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center" id="woltable">
<tr>
<td class="tcat" colspan="$colspan"><div class="smallfont">
<span style="float:$stylevar[right]">
<a href="$reloadurl"><strong>$vbphrase[reload_this_page]</strong></a>
</span>
<strong><phrase 1="$numbervisible" 2="$numberguests">$vbphrase[x_members_and_y_guests]</phrase></strong> - <phrase 1="$recordusers" 2="$recorddate" 3="$recordtime">$vbphrase[most_users_ever_online_was_x_y_at_z]</phrase>
</div></td>
</tr>
<tr>
<td class="thead" >
<span style="float:$stylevar[right]">
<a href="$sorturl&order=desc&sort=time&pp=$perpage&page=$pa genumber">$vbphrase[last_activity]</a> $sortarrow[time]
</span>
<a href="$sorturl&order=asc&sort=username&pp=$perpage&page= $pagenumber">$vbphrase[username]</a> $sortarrow[username]
</td>
<td class="thead" nowrap="nowrap"><a href="$sorturl&order=asc&sort=location&pp=$perpage&page= $pagenumber">$vbphrase[location_temp]</a> $sortarrow[location]</td>
<if condition="$show['ip']"><td class="thead" nowrap="nowrap">$vbphrase[ip_address]</td></if>
<if condition="$vboptions['showimicons']"><td class="thead" align="center" nowrap="nowrap">$vbphrase[instant_messaging]</td></if>
</tr>
$onlinebits
</table>
<if condition="$show['ajax_resolve']">
<script type="text/javascript" src="clientscript/vbulletin_ajax_wolresolve.js?v=$vboptions[simpleversion]"></script>
<script type="text/javascript">
<!--
vB_AJAX_WolResolve_Init('woltable');
//-->
</script>
</if>
<br />
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td class="alt1" align="center">
<form action="online.php" method="post">
<input type="hidden" name="pp" value="$perpage" />
<input type="hidden" name="sortfield" value="$sortfield" />
<input type="hidden" name="sortorder" value="$sortorder" />
<div class="fieldset" style="margin:0px">
<if condition="$vboptions['WOLguests']">
$vbphrase[display]:
<select name="who">
<option value="all" $whoselected[0]>$vbphrase[all]</option>
<option value="members" $whoselected[1]>$vbphrase[members]</option>
<option value="guests" $whoselected[2]>$vbphrase[guests]</option>
<if condition="$vboptions['enablespiders']">
<option value="spiders" $whoselected[3]>$vbphrase[search_bots]</option>
</if>
</select>
</if>
<if condition="$show['ip']">
$vbphrase[user_agent]:
<select name="ua">
<option value="1" $uaselected[1]>$vbphrase[yes]</option>
<option value="0" $uaselected[0]>$vbphrase[no]</option>
</select>
</if>
$vbphrase[per_page]:
<input type="text" class="bginput" style="font-size:11px" name="pp" value="$perpage" size="2" />
<input type="submit" class="button" value="$vbphrase[display]" accesskey="s" />
</div>
</form>
</td>
</tr>
</table>
<if condition="$pagenav">
<table cellpadding="0" cellspacing="0" border="0" width="100%" style="margin-top:3px">
<tr valign="top">
<td align="$stylevar[right]">$pagenav</td>
</tr>
</table>
</if>
<br />
<!-- icons and forum jump -->
<table cellpadding="0" cellspacing="2" border="0" width="100%">
<tr valign="bottom">
<td width="100%">
<table cellpadding="2" cellspacing="0" border="0">
<col align="center"></col>
<tr>
<td><strong>+</strong></td>
<td class="smallfont"> $vbphrase[user_is_on_your_buddy_list]</td>
</tr>
<if condition="$show['hidden']">
<tr>
<td><strong>*</strong></td>
<td class="smallfont"> $vbphrase[user_is_invisible_to_others]</td>
</tr>
</if>
<if condition="$show['badlocation']">
<tr>
<td><img src="$stylevar[imgdir_statusicon]/wol_lockedout.gif" alt="$vbphrase[viewing_forum_closed]" /></td>
<td class="smallfont"> $vbphrase[viewing_forum_closed]</td>
</tr>
<tr>
<td><img src="$stylevar[imgdir_statusicon]/wol_nopermission.gif" alt="$vbphrase[viewing_no_permission_message]" /></td>
<td class="smallfont"> $vbphrase[viewing_no_permission_message]</td>
</tr>
<tr>
<td><img src="$stylevar[imgdir_statusicon]/wol_error.gif" alt="$vbphrase[viewing_error_message]" /></td>
<td class="smallfont"> $vbphrase[viewing_error_message]</td>
</tr>
</if>
</table>
</td>
<td>
$forumjump
</td>
</tr>
</table>
<!-- / icons and forum jump -->
$footer
</body>
</html>
I want to create a new section for the "who's in chat" right below "users registered today" and above "total members visited 24hrs...."
http://www.talkjesus.com/
Hint please? Thanks.
MoT3rror
12-27-2007, 03:01 AM
Sorry told you the wrong template. It is in FORUMHOME and find this code. <!-- what's going on box -->This is the start of the who online at the bottom of the page.
I can't tell you exactly where to past your code because I don't have those mods installed but use the comments tags and that should tell you where everything begins and ends.
JasonP007
12-29-2007, 09:32 PM
hello MoT3rror, i have created the plugin, but not the product, could you walk me through this phase please? i also have realchat integrated and would like to show "who is in chat" and "how many are in chat"
i would really appreciate it...
jason
www.stocknetworkonline.com
MoT3rror
12-29-2007, 09:46 PM
Plugins & Products -> Manage Products -> Add/Import Product
Then when you create the plugin choose the product you called it.
Here is a mod for flash chat.
https://vborg.vbsupport.ru/showthread.php?t=120926&highlight=flash+chat
JasonP007
12-29-2007, 10:24 PM
the link for flashchat? will that help me with realchat?
ok, i did that much and this appears on my forums page at the top???
Parse error: syntax error, unexpected '<' in /home/stocknet/public_html/snoforums.php(63) : eval()'d code on line 1
MoT3rror
12-30-2007, 12:45 PM
This will only work for API Chat. You will have to use something else for other chats.
Put this code in the plugin for APIChat
function getAPI($command) {
$er = error_reporting(0);
$result = file_get_contents("http://chathost:controlport/?api.".$command);
//Replace http://chathost:controlport with the link to the your api chat
error_reporting($er);
return $result;
}
$apichat['currentuserslocation'] = getAPI("whowhere");
Remember to replace http://chathost:controlport with the link to the your api chat or this will not work. I suggest trying this on a test board before you put it on your main site to make sure it works. I suggest creating a new product by Plugins & Products -> Manage Product -> Add New Product. Then add the plugin to the product you created.
Then you can put $apichat[currentuserlocation] in your FORUMHOME template.
JasonP007
12-30-2007, 03:48 PM
I created a product --> then created the plugin and placed the code in there --> lastly i placed the $apichat[currentuserlocation] in the FORUMHOME --> resulting in nothing to display on the forum homepage.
Any advice would be greatly appreciated... I see on chadi's site that he was able to get this to work. I have the same chat software imbedded in my vBulliten so when a vBulliten member enters chat they enter with the registered name.
Thanks in advance...
Jason
MoT3rror
12-30-2007, 08:32 PM
Did you allow your website IP address in Real Chat. Also the variable you need to put in is $apichat[currentuserslocation]. Forgot the s after user
JasonP007
12-30-2007, 11:35 PM
I am not sure what you mean by my website IP address in RealChat? This is the start of the url...
http://64.131.88.242:8080/?nn=
MoT3rror
12-31-2007, 01:07 AM
Is the IP address of your website/server, that your website is stored on, allowed to access your chat.
API commands are served by the built-in Control Center HTTP server and are accessible from trusted IPs only.
Chadi
04-03-2008, 06:24 PM
Ok, not sure what happened here. I had to do a backup file restore earlier in the morning. It was a backup that I made prior to making some changes (and then restoring the backup due to some mishaps). Everything worked fine prior to the backup I generated, including Real Chat user count out put. After the restore, the out put worked fine until I just noticed now it shows blank.
Odd enough, it worked immediately after the restore was done. I stopped, restarted realchat daemon and that did not help. On a side note, the chat itself works fine. No templates were re-modified either, port is still open in firewall of course. I'm a little confused why this is happening. Nothing at all was modified on the server nor anything within realchat / vbulletin after the restore was completed.
forumhome:
<div class="editor" align="center">
<b>Members in Live Chat:
<font size="5">$apichat[currentuserlocation]</font></b>
</div>
Plug-in is active too
function getAPI($command) {
$er = error_reporting(0);
$result = file_get_contents("http://talkjesus.com:8085/?api.".$command);
error_reporting($er);
return $result;
}
$apichat['currentuserlocation'] = getAPI("UserCount");
$apichat['currentusers2'] = getAPI("UsersIn=Chat%20Cafe");
$apichat['currentusers3'] = getAPI("UsersIn=Prayer%20Room");
$apichat['currentusers4'] = getAPI("UsersIn=Teen%20Hangout");
$apichat['currentusers5'] = getAPI("UsersIn=Parent%20Meetup");
$apichat['currentusers6'] = getAPI("UsersIn=Women%20of%20God%20United");
$apichat['currentusers7'] = getAPI("UsersIn=Men%20of%God");
$apichat['currentuserfooter'] = getAPI("UserCount");
Chadi
04-03-2008, 07:44 PM
Another thing I just noticed, even Wimpy mp3 player is showing up in the frame crushed, tiny - or minimized to say. Two other members confirmed they see the same result.
The template in VB is still the same.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.