As a first step in our Facebook application, we’ll be retrieving some basic information about a logged in user who is visiting our application.
fbuser = User.objects.get_current()
# Get some specifics about the user
user_details = request.facebook.users.getInfo([fbuser.id], ['first_name, current_location']);
name = user_details[0]['first_name']
current_location = user_details[0]['current_location']
This is pretty straightforward. First we get a user object for the logged in Facebook user using the User.objects.get_current() method.
Then we’ll use the user’s ID to gather some basic information about the user, i.e. first_name and current_location. It’s important to note that the user information that can be retrieved depends whether you’re passing a session variable.
While the method doesn’t require a session key, without one you’re limited to the following:
- uid
- first_name
- last_name
- name
- locale
- affiliations (regional type only)
- pic_square
- profile_url
The same restrictions are in place if the user has not yet installed our application.
If you have a session key and the user has installed our application, the sky’s the limit. See the Users.getInfo documentation for a complete list of what’s available.
As always, I welcome comments and constructive criticism. I am by no means an expert at this so I can already anticipate there are better ways to accomplish the things I’m trying to do.
No comments:
Post a Comment