Facebook粉丝页面选项卡和用户ID [英] Facebook fan page tab and user id

查看:186
本文介绍了Facebook粉丝页面选项卡和用户ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据以下链接中的文档,如果用户将与表单交互,我们可以获取用户ID.

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

"如果查看用户与选项卡进行了交互(例如提交表单,执行了导致AJAX加载新内容或遵循选项卡上加载的相对URL的操作),则该用户的UID将发送到应用程序作为fb_sig_user参数,配置文件所有者的用户ID作为fb_sig_profile_user参数发送.仅当用户授权应用程序时,查看用户的会话密钥为key.

在我的粉丝页面标签中,我有一个AJAX表单,用户可以使用该表单提交一些值..现在我还需要用户ID.如何获取此文件.

我尝试使用$ _POST ['fb_sig_user']获取AJAX提交页面中的值,但没有成功..任何人都可以帮我这个忙..

解决方案

除非您通过在Facebook的ajax函数中对用户进行身份验证,否则您将无法使用$_POST['fb_sig_user']获取用户的ID:

ajax.requireLogin = true;

例如,我正在使用它进行检索:

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);
}

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..

解决方案

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);
}

这篇关于Facebook粉丝页面选项卡和用户ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆