【问题标题】:Issue retrieving friendlists from Facebook through Koala gem通过 Koala gem 从 Facebook 检索好友列表的问题
【发布时间】:2013-04-06 05:27:41
【问题描述】:

我正在处理一个由其他人发起的项目,该项目通过 Koala gem 与 Facebook 进行交互。出于某种奇怪的原因,它允许我创建朋友列表,但是当我检索它们时,我什么也得不到。我可以使用 Facebook 的 Graph API Explorer 工具验证我是否有通过 Graph API 可用的朋友列表,并且我在应用程序中确实拥有“manage_friendlists”权限。我还可以验证它是否通过此应用程序成功添加了朋友列表,并且尝试添加同名的朋友列表将返回错误(它应该)。然而,当它通过应用程序实际检索它们时,它只是返回哈希

{:me => {:id => 'my_id'}} 

没有别的。方法写成

  def friendlists
    graph_api.get_objects('me', {fields: 'friendlists'})['me']['friendlists']['data']
  end

它给出了一个'undefined method [] for nilClass',因为没有'friendlists'嵌套哈希返回。如果这有什么不同,我正在使用 Koala 1.4.0。有什么想法或建议吗?谢谢!

【问题讨论】:

    标签: facebook sinatra koala


    【解决方案1】:

    我也在用koala gem……你可以这样使用:

    session['fb_access_token']是用户登录时的那个,我分配如下:

    session['fb_access_token'] = auth['credentials']['token']
    
    def self.fetching_facebook_friends 
        @graph = Koala::Facebook::API.new(session['fb_access_token'])
        profile = @graph.get_object("me")
        @profile_image = graph.get_picture("me")
        friends = @graph.get_connections("me", "friends?fields=id, name, picture.type(large)")
    end 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-13
      • 1970-01-01
      • 2012-02-24
      相关资源
      最近更新 更多