我希望获得一个真正的Facebook链接。 所以在使用Omniauth Gem进行身份验证后,我已经像这样链接: https://www.facebook.com/app_scoped_user_id/960601127305294/ 但我的真实个人资料链接是:https://www.facebook.com/kuzevanoff
因此,对于我的系统,有两个不同的链接。
如何解决我的问题?
谢谢!
My Omniauth hash:
Started GET "/auth/facebook" for 127.0.0.1 at 2015-05-31 13:40:45 +0200
I, [2015-05-31T13:40:45.979688 #56787] INFO -- omniauth: (facebook) Request phase initiated.
<OmniAuth::AuthHash credentials=#<OmniAuth::AuthHash expires=true expires_at=1438249229 token="CAAXPwjr1V5oBABodmqtUPAGyPhnMBo3v7Q0Jifa8c7ZAYvvxYQiJoAydA1zJdeB6x9Gq8tRJFkEUeZAs003MnEe2mseO09UQwY3uvrS2JpodVqIauqRZAxUFbHBW234BB9s4q31WKpeOmbEzZBfmnP1cpowO3UWTOhfsfqFJObiPsZCKFPlZAjBH3rP6Fl6ldl62jUcLHDSIu7xubWPTvT"> extra=#<OmniAuth::AuthHash raw_info=#<OmniAuth::AuthHash email="boriska-iriska@yandex.ru" first_name="Boris" gender="male" id="960601127305294" last_name="Kuzevanov" link="https://www.facebook.com/app_scoped_user_id/960601127305294/" locale="ru_RU" name="Boris Kuzevanov" timezone=2 updated_time="2015-05-03T21:09:59+0000" verified=true>> info=#<OmniAuth::AuthHash::InfoHash email="boriska-iriska@yandex.ru" first_name="Boris" image="http://graph.facebook.com/960601127305294/picture" last_name="Kuzevanov" name="Boris Kuzevanov" urls=#<OmniAuth::AuthHash Facebook="https://www.facebook.com/app_scoped_user_id/960601127305294/"> verified=true> provider="facebook" uid="960601127305294">
答案 0 :(得分:0)
如果您正在使用omniauth-facebook gem,那么您将获得跟随Auth Hash的request.env['omniauth.auth']
# Example from omniauth-facebook gem
# https://github.com/mkdynamic/omniauth-facebook#auth-hash
{
:provider => 'facebook',
:uid => '1234567',
:info => {
:nickname => 'jbloggs',
:email => 'joe@bloggs.com',
:name => 'Joe Bloggs',
:first_name => 'Joe',
:last_name => 'Bloggs',
:image => 'http://graph.facebook.com/1234567/picture?type=square',
:urls => { :Facebook => 'http://www.facebook.com/jbloggs' },
:location => 'Palo Alto, California',
:verified => true
},
# Removed non-essential part for brevity..
}
正如您所见,个人资料网址可通过信息获取&gt;网址&gt; Facebook的。此外,您只需将昵称附加到根URL即可获取配置文件链接。
"http://www.facebook.com/" + omniauth_hash.info.nickname