Sunday, May 2, 2010

Facebook login button

This post is about the agony facebook makes its developer goes through with inadequate documentation, poor linking of pages and alien language (xfbml) which never behaves the I expect it to. Anyway this is how I got facebook login working on my site.
Problem: I used the facebook login on my site http://fewbs.com/login. It appeared fine and easily but the popup which opened for login never closed and opened the root of my site.
Solutions on web:
1. Most of them used receiver_htm file in the FB.init which I was not using so it was quite confusing whether or not I was doing the right thing.
2. Some said that fb:login-button takes onlogin attribute which really helped me take the next step
3. Others said that onlogin method should take "document.location.href=document.location.href". This did not work for me.
My solution:
A combination and a variant of the above solutions here :-
Use the code below at the bottom of your page in script tags

window.onload = function(){
FB.init({appId: 'xxxxxxxxx', status: true, cookie: true,xfbml: true});
}
function doFBLogin()
{
FB.api('/me', function(response) {
//your code here
});
}

Use the codebelow to place the login button.
<fb:login-button onlogin="doFBLogin();"></fb:login-button>

There are couple of other options for fb:login-button which can be found here
http://wiki.developers.facebook.com/index.php/Fb:login-

UPDATE: I think the login popup closes automatically if it finds any meaningful JS expressions in the onlogin attribute.

Wednesday, February 3, 2010

Flash not rendering in apps

I am staring to write again after a long time to log my technical experience gained during the development of fewbs

I will discuss about firefox issue of flash rendering today. I am using Firefox 3.5.7 with Flash 10.
Problem: Flash based widgets were not rendering on the tabs i.e. I could hear the sound from them but they were not rendering.
Solution on web:
1) Doctype issues as given on experts-exchange

2) An old bug of firefox 3 and Flash 9 which I thought was not relevant. Adobe notes


RCA: When switch of tab is made in fewbs(not in firefox) the last tab's display was set to none and the current's one to block. As a result the contents of flash movie in the hidden tab rolled back to beginning and movie stops playing. When
the user goes to the last tab, firefox loads the whole movie again. To fix this, I used zIndexes to place the frame over each other and fool firefox that the the tab is still active.
Due to this, firefox intermittently stopped rendering flash movies even in the current tab as apps. It was frightening at first as I thought I might have hit a firefox bug. Excluding youtube from embeddable apps section seemed like a death stone.
Soltuion: After hours of digging, I, thankfully, noticed the above happening. Now I no longer use zIndexes. I quietly transport the tabs to a style top value of -1000px :)