0

I'm a little bit confused on the process of obtaining a user's friends list using the frameworks django_facebook and userena.

This is confusing because {{ request.user.get_profile.friends }} returns an empty list for a user with friends, and this isn't a permissions error because {{ request.user.get_profile.access_token }} actually properly returns the access token, which means the friends list for that user can be accessed from https://graph.facebook.com/me/friends?access_token={{ request.user.access_token }}

I read the documentation and the code but still can't figure out why the friends list or the likes list are not returning anything (everything else works). If anyone is willing to help that would be wonderful (sorry this question is a bit obscure).

The code for the framework is here:

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

specifically line 50 of (where friends are returned from a user): https://github.com/tschellenbach/Django-facebook/blob/master/django_facebook/models.py

Thanks

Lucas Ou-Yang
  • 5,505
  • 13
  • 43
  • 62

1 Answers1

0

Basically, you have to call "get_and_store_friends" first to save friends data into the database. I just tested it out and have my code below:

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')

Here is the documentation. http://django-facebook.readthedocs.org/en/latest/api.html

Rui Xia
  • 175
  • 4
  • 20