当我使用通过Facebook开发人员部分创建的测试用户测试我的应用时,那些测试用户的Facebook好友确实被抓取了,但是当我使用真实账户和真正的朋友时。真正的Facebook帐户是Facebook应用程序的用户,因为他们使用facebook omniauth在我的网站上注册。我不明白为什么会这样。有没有人有这种问题的经验?
def get_facebook_friends
if current_user.identities.where(provider: 'facebook').exists?
#just use user' existing facebook credentials
identity = current_user.identities.where(provider: 'facebook').first
facebook = Koala::Facebook::API.new(identity.token)
@ffriends = facebook.get_connections("me", "friends?fields=id,name,picture.type(large)")
@number_of_friends = @ffriends.length
session['ffriends'] = @ffriends
session['number_of_friends'] = @number_of_friends
@facebook_main_2 = "block"
@facebook_main_1 = "none"
binding.pry
else
#have user sign_in to facebook
session['redirect_to'] = get_facebook_friends_path
redirect_to user_facebook_omniauth_authorize_path
end
end