Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7504061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:26:37+00:00 2026-05-29T21:26:37+00:00

When a user registers for my site through Facebook. It returns 3 friends have

  • 0

When a user registers for my site through Facebook. It returns “3 friends have registered” next to the ‘Register’ button with the Facebook authentication API.

def facebook_authenticated(request):
    try:
        code = request.GET['code']
    except:
        return HttpResponseRedirect('/?error=facebook')

    redirect_url = "yaddayadaa"

    args = dict(client_id=settings.FACEBOOK_API_ID, redirect_uri=redirect_url)
    args["client_secret"] = settings.FACEBOOK_API_SECRET
    args["code"] = code

    response = cgi.parse_qs(urllib.urlopen(
        "https://graph.facebook.com/oauth/access_token?" +
        urllib.urlencode(args)).read())
    access_token = response["access_token"][-1]

    graph_url = "https://graph.facebook.com/me?access_token="+access_token

    profile = json.load(urllib.urlopen(graph_url))

    member_id = str(profile['id'])

    try:
        new_user = FacebookProfile.objects.get(facebook_id=member_id).user
        fbprofile = FacebookProfile.objects.get(user=new_user)
        if access_token != fbprofile.access_token:
            fbprofile.access_token = access_token
            fbprofile.save()
    except (User.DoesNotExist, ObjectDoesNotExist):
        return HttpResponseRedirect('/?error=facebook')

How would I get the 3 users and store, such that the registering user can connect with them on my site?

I haven’t found any examples of how to accomplish this, or what parts of the API are useful to do this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T21:26:39+00:00Added an answer on May 29, 2026 at 9:26 pm

    Once that user accepts permissions to your app, you can call the /me/friends to get a list of friends, then you can parse thru that list looking at the installed property to determine if that friend is one of your app users.

    Another way, the better of the two as only one call as well as no parsing after the call, would be to use FQL to query the friends list

    fql?q=SELECT uid, name, is_app_user FROM user WHERE uid IN (SELECT uid1 FROM friend WHERE uid2=me()) and is_app_user=1

    EDIT

    PHP example of how to run FQL code. Taken from http://developers.facebook.com/docs/reference/fql/

    <?php
      $app_id = 'YOUR_APP_ID';
      $app_secret = 'YOUR_APP_SECRET';
      $my_url = 'POST_AUTH_URL';
    
      $code = $_REQUEST["code"];
    
     //auth user
     if(empty($code)) {
        $dialog_url = 'https://www.facebook.com/dialog/oauth?client_id=' 
        . $app_id . '&redirect_uri=' . urlencode($my_url) ;
        echo("<script>top.location.href='" . $dialog_url . "'</script>");
      }
    
      //get user access_token
      $token_url = 'https://graph.facebook.com/oauth/access_token?client_id='
        . $app_id . '&redirect_uri=' . urlencode($my_url) 
        . '&client_secret=' . $app_secret 
        . '&code=' . $code;
      $access_token = file_get_contents($token_url);
    
      // Run fql query
      $fql_query_url = 'https://graph.facebook.com/'
        . '/fql?q=SELECT+uid2+FROM+friend+WHERE+uid1=me()'
        . '&' . $access_token;
      $fql_query_result = file_get_contents($fql_query_url);
      $fql_query_obj = json_decode($fql_query_result, true);
    
      //display results of fql query
      echo '<pre>';
      print_r("query results:");
      print_r($fql_query_obj);
      echo '</pre>';
    
      // Run fql multiquery
      $fql_multiquery_url = 'https://graph.facebook.com/'
        . 'fql?q={"all+friends":"SELECT+uid2+FROM+friend+WHERE+uid1=me()",'
        . '"my+name":"SELECT+name+FROM+user+WHERE+uid=me()"}'
        . '&' . $access_token;
      $fql_multiquery_result = file_get_contents($fql_multiquery_url);
      $fql_multiquery_obj = json_decode($fql_multiquery_result, true);
    
      //display results of fql multiquery
      echo '<pre>';
      print_r("multi query results:");
      print_r($fql_multiquery_obj);
      echo '</pre>';
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say a user registers for your site, you hash the password they have chosen
I am having problems with user authentication for my django site. I have a
When a user registers on my site, they have their own table created in
When a user registers with my site I want to offer them a login
This is the standard scenario: User registers on the site User receives an account
In my web application i have registration form, when user register i want to
I have an app that requires user to register. I've got the app conected
We have over 10,000 registered users on our site and want to associate each
I'm running a facebook Connect site where I use Connect for authentication. I check
My site has the option of registering with and without facebook. When you register

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.