Archive for November, 2009

XMPP Facebook Chat

I get a lot of complaints from people who say that the Facebook Chat plugin for Pidgin is “flakey” and disconnects a lot. I’d just like to say, “Its not my fault!” 🙂
I was talking on the phone to someone at Facebook and asked them if they used my plugin. They said “no, I don’t use the public one its really buggy but I am beta testing our new interface internally which is a lot better.” Once he found out that I actually wrote the plugin, he did a bit of a turnaround and went on to explain that the server software isn’t really the greatest, that it puts a heavy load on their servers and that it was actually all their fault that my plugin was so bad 🙂

So, after a bit of snooping around, I discovered the details of the XMPP servers. You can even (almost) connect to them. For now, it looks like you have to be authorized in their beta programme (or probably just be working at Facebook) to be able to use it.

The XMPP server is running at chat.facebook.com:5222 and it uses DIGEST-MD5 for authentication as well as something called “X-FACEBOOK-PLATFORM” for SASL. In Pidgin you can set up the account by using your username, with the domain chat.facebook.com, disabling the “Require SSL/TLS” option in the advanced tab. Doesn’t look like its working with s2s yet, but hard to tell without being able to log in.

So give it a go, maybe your account slips through the cracks and you can log in. Will been keen to hear from anyone about their successes/failures with this.

6 Comments

Taming the GAM beast

One of the things I have to do in my day-job is manage our Google Ad Manager system, which we call GAM. One of the downsides of using GAM (actually a lot of different ad management systems) is their use of the javascript function document.write(), as well as their requirement to load in a big whomping load of javascript in the <head> of the page. One of the keys of website optimisation is to load all javascript at the end of your HTML page, so that the webpage renders as quickly as possible.

The way we can deal with this is overload the document.write() function to bend to our own wicked ways. Normally, you load the GAM code at the top of the page, but we’ll put it at the bottom and use a neat little function I wrote.

function insertAds(AdSlotName, width, height)
{
var slot = document.getElementById('my_ads_'+AdSlotName);
if (!slot)
return;
var oldwrite = document.write;
document.write = function(text){slot.innerHTML+=text};
GA_googleFillSlotWithSize("ca-pub-yournumhere", AdSlotName, width, height);
document.write = oldwrite;
}

Now we just slap in a <div> with our ad slots name, so we’ll replace
<script type="text/javascript">GA_googleFillSlotWithSize("ca-pub-yournumhere", "AdSlotName-760x120", 760, 120);</script>
with
<div id="my_ads_AdSlotName-760x120">&nbsp;</div>
(which will render faster)
Then load in the ad at the bottom of the page:
<script type='text/javascript'><!--
insertAds("AdSlotName-760x120", 760, 120);
// --></script>

And there you have it. You can take out some more javascript from your <head> and speed things up a bit. My own speed tests showed between one-and-a-half to two seconds decrease in start-rendering time. Would be interested to hear your own findings.

4 Comments