Facebook fan page tab and user id

In accordance with the documentation at the following link, we can get the user ID if uer interacts with the form.

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

"If the viewer interacts with the tab (for example, submits a form, performs an action that causes the loading of new AJAX content, or follows a relative URL that loads on the tab), this user UID is sent to the application as the parameter fb_sig_user, the profile owner’s user ID is sent as the fb_sig_profile_user parameter. A user browsing session key is a key that is sent only if the user has allowed the application. "

In my fan page tab, I have an AJAX form that the user can submit with some value. Now I need a user id. How can i get this.

I tried to get the value on my AJAX submission page using $ _POST ['fb_sig_user'] without any success .. can someone help me please with this.

+4
source share
2 answers

You cannot get the user ID using $_POST['fb_sig_user'] unless you authenticate the user by specifying this in the ajax function on facebook:

 ajax.requireLogin = true; 

For example, I retrieve it using 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); } 
+5
source

I gladly used the fb_sig_profile_user form variable for previous applications, and when developing a new application last week, the variable was not where it could be found.

Search for several days, I was going to give up, and then the answer found:

 ajax.requireLogin = true; 

I understand that FB cares about privacy and all, but they really need to announce these changes before simply removing them.

Million Thanks!

+1
source

Source: https://habr.com/ru/post/1305450/


All Articles