Facebook fan page tab and user id

As per the documentation in the following link, we can get the user id if the uer will interact with the form..

http://wiki.developers.facebook.com/ind … d_Policies

"If a viewing user interacts with the tab (like submits a form, takes an action that causes an AJAX load of new content, or follows a relative URL that loads on the tab), that user's UID is sent to the application as the fb_sig_user parameter, the profile owner's user ID is sent as the fb_sig_profile_user parameter. The viewing user's session key is key is sent only if the user authorized the application. "

In my fan page tab am I have an AJAX form which the user can submit with some value.. now I need the users id also.. how can I get this..

I tried to get the value in my AJAX submit page using $_POST['fb_sig_user'] with no success.. can anyone help me with this please..

Answers


You won't be able to get the id of the user using $_POST['fb_sig_user'] unless you authenticate the user by having this in the facebook's ajax function:

ajax.requireLogin = true;

For example, I'm retrieving it fine with this:

function do_ajax(url, div_id)
{
    document.getElementById('poller_waitMessage').setStyle('display', 'block');

    var ajax = new Ajax();
    ajax.responseType = Ajax.FBML;
    ajax.onerror = function(error)
    {
        new Dialog().showMessage("Error:", "Some communication error occured, Please reload the page.","Ok");
    };

    ajax.ondone = function(data)
    {
        document.getElementById('poller_waitMessage').setStyle('display', 'none');
        document.getElementById(div_id).setInnerFBML(data);

    }

    ajax.requireLogin = true; // <----- this is important
    ajax.post(url);
}

I've been happily using the form variable fb_sig_profile_user for previous apps, and when developing a new app last week, the variable was no where to be found.

Searched for several days, I was about to give up, and then the found answer:

ajax.requireLogin = true;

I understand FB cares about privacy and all, but they really need to announce these kinds of changes before just taking it away.

Million Thanks!


Need Your Help

boost::mpl::fold for double parameter abstraction

c++ boost metaprogramming boost-mpl

I have a class called caRender, which provides one caRender::renderClientObject() method per given object type in clientObjectTypes. So the following code snipped shows this running situation: