开发者

Facebooker2. rails and create new user

I want to user facebooker2 for facebook connect functionality. So when the user login with facebook credentials i want to redirect to action create_facebook_user.

So I used this helper of facebooker2:

 <%= fb_login_and_redirect("/users/create_facebook_user", :perms => 'first_name,last_name,email,user_birthday') %>

OK? How can i access to facebook public information as email, first_name,开发者_JS百科 last_name, etc.

My controller is:

def create_facebook_user
  if current_facebook_user
    @user = User.find_by_fb_user_id(current_facebook_user.id.to_i)
  end
  if @user.blank?
    @facebook_user = current_facebook_user.fetch

    @user = User.create :login => @facebook_user.email, :email => @facebook_user.email, :name => @facebook_user.name, :fb_user_id => @facebook_user.id
    if @user.save
      @user.profile = Profile.create(:benefactor_id => nil, :benefactor_invites =>   Setting.find_by_identifier("benefactor_invites").value.to_i)
      redirect_to :controller => "profiles", :action => "show", :id => @user.profile.id
    else
      render "new"
    end
  elsif @user.fb_user_id.nil?
    @user.update_attribute :fb_user_id, current_facebook_user.id
    redirect_to :controller => "dashboard", :url => "index"
  else
    redirect_to :controller => "dashboard", :url => "index"
  end
end

OK, my problem is to obtain user facebook information.


First of all, note that some of the extended permissions you are using do not exist: "first_name" and "last_name". Check the Facebook page about extended permissions.

Once logged in with Facebooker, you can access these fields like this:

current_facebook_user.first_name
current_facebook_user.last_name
current_facebook_user.email
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜