开发者

Facebook.showPermissionDialog

开发者 https://www.devze.com 2023-01-26 12:42 出处:网络
Hello i\'m trying to use facebook showPermissionDialog to get user datas this is my code function switch_menu(element, id) {

Hello i'm trying to use facebook showPermissionDialog to get user datas

this is my code

function switch_menu(element, id) {

      var ajax = new Ajax();
      Facebook.showPermissionDialog('manage_pages,offline_access,email,publish_stream,user_photos,user_birthday')
      ajax.responseType = Ajax.FBML;
      ajax.ondone = function(data) {
        document.getElementById('topic_loading').setInnerFBML(data);
      }
      ajax.onerror = function() {}
      ajax.post('#{oauth_authorize_url(开发者_StackOverflow社区:canvas => false, :format => :js)}')
    }

The dialog is opening very well, my question is how to get the user data after that the user has accepted the conditions.

thx


I guess you have already found the soln to this. Just in case here it is:

Facebook.showPermissionDialog("bla,bla,bla permissions", FacebookPermissionHandler);

function FacebookPermissionHandler(handler)
{
   new Dialog().showMessage('Okay.', ""+handler);
   //handler contains allowed permission(s) [comma seperated] from the user.
}

FB documentation actually explains this.

Please double check the documentation if you cant get this to work.


There is a bug in Facebook.showPermissionDialog() which causes Ajax requests silently fail after user gives you the permissions. Since you are already asking for extra permission you can set ajax.requireLogin to false. This should fix the Ajax request.

function switch_menu(element, id) {
    var ajax = new Ajax();
     Facebook.showPermissionDialog('manage_pages,offline_access,email,publish_stream,user_photos,user_birthday')
    ajax.responseType = Ajax.FBML;
    ajax.requireLogin = false;
    ajax.ondone = function(data) {
        document.getElementById('topic_loading').setInnerFBML(data);
    }
    ajax.onerror = function() {}
    ajax.post('#{oauth_authorize_url(:canvas => false, :format => :js)}')
}
0

精彩评论

暂无评论...
验证码 换一张
取 消