【问题标题】:Obtaining friends in the django_facebook framework在 django_facebook 框架中获取好友
【发布时间】:2012-09-09 08:59:30
【问题描述】:

我对使用框架 django_facebook 和 userena 获取用户朋友列表的过程有点困惑。

这很令人困惑,因为 {{ request.user.get_profile.friends }} 为有朋友的用户返回一个空列表,这不是权限错误,因为 {{ request.user.get_profile.access_token }} 实际上正确返回访问令牌,这意味着可以从https://graph.facebook.com/me/friends?access_token={{ request.user.access_token }}

访问该用户的好友列表

我阅读了文档和代码,但仍然无法弄清楚为什么朋友列表或点赞列表没有返回任何内容(其他一切正常)。如果有人愿意提供帮助,那就太好了(抱歉这个问题有点晦涩)。

框架的代码在这里:

https://github.com/tschellenbach/Django-facebook

特别是第 50 行(从用户那里返回朋友): https://github.com/tschellenbach/Django-facebook/blob/master/django_facebook/models.py

谢谢

【问题讨论】:

    标签: python django django-facebook


    【解决方案1】:

    基本上,您必须先调用“get_and_store_friends”才能将好友数据保存到数据库中。我刚刚对其进行了测试,下面有我的代码:

    from django.http import HttpResponse
    from django_facebook.api import FacebookUserConverter, get_facebook_graph
    
    def main(request):
        open_graph = get_facebook_graph(request)
        converter = FacebookUserConverter(open_graph)
        converter.get_and_store_friends(request.user)
        return HttpResponse('None')
    

    这是文档。 http://django-facebook.readthedocs.org/en/latest/api.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-09
      • 2011-04-29
      • 1970-01-01
      • 1970-01-01
      • 2014-07-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多