내가 OAuth를하고 (지정된 here 및 here 같은) fb_graph 보석으로 책정 해 사용하고 찾을 수있는 가장 좋은 방법. 내 gemfile 구성은 다음과 같습니다 그래서 버전에 문제가 있었다 :
gem 'devise', :git => 'git://github.com/plataformatec/devise.git'
gem 'omniauth', '>=0.2.0.beta'
gem 'oa-oauth', :require => 'omniauth/oauth'
gem 'fb_graph'
(내 설정은 매우 오래 - 지금은 더 아웃 - 오브 - 박스 방식으로 omniauth 지원하는 최신 지점을 고안이 가능) .
내 유증 이니셜 : 귀하의 사용자 모델에서
config.omniauth :facebook_publish, "APP_ID", "APP_SECRET"
:
devise :omniauthable
와 페이스 북을 위해
def self.find_for_facebook_oauth(access_token, signed_in_resource=nil)
data = access_token['extra']['user_hash']
if user = User.find_by_email(data["email"])
user
else # Create a user with a stub password.
User.create(:email => data["email"], :password => Devise.friendly_token[0,20])
end
end
연결 - 경로로 이동합니다
user_omniauth_authorize_path(:facebook)
기본적으로 이것이 연결에 필요한 것입니다.
facebook_user = FbGraph::User.new('me', :access_token => access_token['credentials']['token']).fetch
그리고 친구를위한
:
facebook_user.friends
을 그리고 그것 뿐이다 그래프를 얻기 위해 지금 사용합니다. 희망이 도움이됩니다.
나는 이것이 꽤 오래되었다는 것을 알고 있지만 facebook_user = ... FBGraph 부분은 어디에 두는가? – stewart715
컨트롤러 또는 모델 (친구 목록을 가져와야하는 곳). – Drakmail