0
我想用戶facebooker2的facebook連接功能。因此,當用戶使用Facebook憑證登錄時,我想重定向到操作create_facebook_user
。Facebooker2。導軌,並創建新的用戶
所以我用這個幫手facebooker2:
<%= fb_login_and_redirect("https://stackoverflow.com/users/create_facebook_user", :perms => 'first_name,last_name,email,user_birthday') %>
OK?我怎麼能訪問Facebook的公共信息,電子郵件,名字,姓氏等
我的控制器:
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,我的問題是獲取用戶的Facebook信息。
對不起我didn't使用fetch方法。謝謝。但是,您可以看到我的其他帖子。再次感謝。 – maxiperez 2011-04-13 16:52:32