【问题标题】:Get friendship start date获取友谊开始日期
【发布时间】:2011-09-13 10:03:33
【问题描述】:

我一直在寻找一种方法来了解两个用户成为朋友的日期。我找到了this question,但它只解释了如何使用多个 FQL 查询来模拟友谊页面。

我要确定的是您可以在友谊页面顶部看到的日期(“Facebook 朋友自从...”)。

【问题讨论】:

    标签: facebook-graph-api social-network-friendship


    【解决方案1】:

    我以一种无可否认的方式做到了这一点。您可以使用posts 端点获取所有帖子,然后选择包含“现在朋友”字样的帖子。 story_tags 字段将包含一个描述朋友详细信息的对象。在 Rails 中,您可以使用 facebook gem 来执行此操作:

    # To retrieve your friendship start dates
    user = {fb_id: <your fb id>, auth_token: <your fb auth token>}
    fb_user = FbGraph::User.me(user[:auth_token])
    posts = fb_user.posts(:since => 10.days.ago.to_i, :until => Time.now.to_i)
    posts = posts.reject{|p| p.story.nil? || (!p.story.include?("now friends"))}
    posts.each do |p|
      p.story_tags.each do |t|
        unless t.identifier == user[:fb_id]
          puts "You became friends with #{t.name} at #{p.created_time}"
        end
      end
    end
    

    哪些输出:

    You became friends with Christina Ricci at 2013-01-12 20:34:58 UTC
    You became friends with Michael Jordon at 2013-01-09 19:51:51 UTC
    You became friends with Barack Obama at 2013-01-04 19:06:51 UTC
    

    【讨论】:

      【解决方案2】:

      无法通过 Graph API 或 FQL 表获得此日期。您可以通过 Facebook 记录功能请求,或通过您在帖子中链接的变通方法获得创意。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-07-01
        • 2023-03-14
        • 2016-07-08
        • 1970-01-01
        • 2012-05-15
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多