There is full read and write chat functionality now added to the API :)

Who wants to write two-way IRC<-->DaniWeb Chat integration? ;)

Any takers ... ??

You need an access token in order to post, but it's feasable if you create a new DaniWeb account named "IRC Bot" and have everything posted from the IRC channel posted by the bot (perhaps the message can be preceded by the nick in parentheses or some such).

~s.o.s~ commented: Good work! +0

Perhaps this will inspire some to participate in the contest.

Either that or you win by default me thinks!

That wasn't the plan. You're up either late, or very early ;)

Up late ... nearly 5 am, geez.

That's when I get up, and am in the office for 5.30am most mornings...

Something else I'd love to see done: I'd like to pull in my Twitter tweets and Facebook status messages into my Shoutbox.

Member Avatar

Chat sounds interesting, hadn't noticed the changes to the API.

So, you wouldn't be too impressed with somebody calling a fetch every few seconds then, to replicate 'a live feed'?

That would be fine. Chat was added to the API specifically to offer the ability to create a live chat application, so polling just comes with the territory.

I'll go ahead and see if I can add long polling to the API as well.

OK, long polling set up!! :)

Member Avatar

Nice one Dani. I may have a pop at creating an app with this - although too late for comp. :)

Awesome :) Yeah, I think some features with the chat would be much appreciated by all, especially since it has write capability.

hadn't noticed the changes to the API.

Some version info would be nice. Just noticed changes to the get chat, would be nice if there was a history of sorts, make it easier to keep track.

Yeah, sorry about that. :( I was going to start a new thread mentioning the changes but I held off figuring no one started working with chat yet :(

Member Avatar

I keep getting error messages wrt timing out. I've only started playing, so it's probably me. :)

Are you using the long polling version or the short polling version?

Member Avatar

long- but not sure if I had it set up correctly. will try again (I trashed the code).

//tried something different - worked !

OK cool. Yeah, you just need to put it in a while loop where as soon as it sends something back, immediately make another call.

Member Avatar
var old;
function getChat()
            var gr = $.parseJSON(data);
                str = '';
                if(old !==  data){
                    old = gr;
                        str += "<strong>" + v.chatter.username + ": </strong>" + v.message + "<br />"; 


That's my rough draft. I'll tidy it up with just appending new data by getting the latest post, instead of writing the whole thing every time.

Not sure what danichat.php does, but yeah, the JSON will include a data array in addition to a polling array that contains the last ID # retrieved. You'll want to pass that back in ....... on that note, please don't kill me, but I accidentally changed last_id to since_id so I just changed it back to last_id. Don't kill me!! :)

since_id so I just changed it back to last_id

Aargh... just changed that...

Member Avatar

please don't kill me, but I accidentally changed last_id to since_id so I just changed it back to last_id

I got dis buddy in Lawn Guyland, who duz de odd job for me. Maybe I pay him to give you a call, huh?

Not sure what danichat.php

That's just the file_get_contents.

since_id so I just changed it back to last_id

And you haven't updated the docs...

BTW, long polling states true/false, but your example shows a 1. Even if I poll the forum chat (3) with a high ID, it still returns directly. Shouldn't this wait for 30 seconds?

Member Avatar
<div id="chat"></div>
<div id="clock"></div>

<script src="//"></script>
<script type="text/javascript">
var last = false;
var clock = 0;

    function getChat(lp)
        defaultStart = 10269;
        usenum = (lp == 1) ? defaultStart : lp;
            url: '', 
            data: {long_polling: 1, last_id: usenum},
            dataType: 'jsonp'
            id = data.polling.last_id;
            chatData =;
            if(last == false)
            }else if(last !== id){
            last = id;

    function initializeChat(data)
        str = '';
        $.each(data, function(i,v){
            str += '<strong>' + v.chatter.username + ':</strong> ' + v.message + "<br />";  


    function appendChat(chatData)
        alert('called'); //write append data again      

    function clockIt()
        clock = clock + 1;


Just tried this code - works after a fashion, no php being used this time :) ANyway, I thought you were running a long poll (approx 30 seconds?). My code is running extremely quickly. About 90 times / minute. It shouldn't be doing that should it? Seems the api is returning data immediately as opposed to long polling - or have I made an error (again)?

Seems the api is returning data immediately as opposed to long polling

I've come to the same conclusion in PHP.

Does the polling add "clicking around somewhere" to the online stats?

I accidentally changed last_id to since_id so I just changed it back to last_id

You're confusing. Why not just say "it should be since_id". Works now.

The problem was (since diafol and I must've been using last_id) that the id starts at 0 (when omitted), and the full result is returned every time.

I did ... on the previous page. But I changed it in too many places so one of the places I changed it to had to be changed back to last_id. That's what I meant where you quoted me.