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

  • Home
  • SEARCH
  • 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 6704497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:17:43+00:00 2026-05-26T07:17:43+00:00

Here is what I am working with, I have simplified it a little: if

  • 0

Here is what I am working with, I have simplified it a little:

if (response.authResponse) {
    FB.api('/me', function(response) {
        response.id;

        user_id = response.id; // I thought I could at least access it below if it was defined globally...

    });     

    var friend_list = [];
    FB.api('/me/friends', function(response) {

        $.each(response.data,function(index,friend) {

            friend_list.push(friend.id);

        });

        user_friend_list = friend_list.toString();

    });  


    alert("user id:"+user_id+"friend list:"+user_friend_list); // Here is where I would like these two variables to show up

} else {
    //user cancelled login or did not grant authorization

}

probably for some obvious reason (due to my poor javascript and jquery) I cannot capture the variables. If you provide an answer please explain a little so I can gain insight and learn.

  • 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-26T07:17:44+00:00Added an answer on May 26, 2026 at 7:17 am

    Try this.

    if (response.authResponse) {
        FB.api('/me', function(data) {
            var user_id = data.id;
            FB.api('/me/friends', function(response) {
                var friend_list = [];
                for (i = 0; i < response.data.length; i++) {
                    friend_list.push(response.data[i].id);
                }
                //user_friend_list = friend_list.join(",");
                alert("user id:" + user_id + "friend list:" + friend_list.join(","));
            });
        });
    }
    else {
        alert("no access granted");
    }
    

    Altered bits and pieces of code. Comment if you have a problem with this solution.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is a simplified version of what I have (not working): prog.h: ... const
What I have here is a PHP page working with the Facebook API. What
Here's a simplified version of a problem I'm working on: I have a bunch
I have createn an app, this app can be found here Everything is working
I have a homework problem here I've been working on; here is the description:
Here's the code for a simple page I have that is not working: <head>
Here's what I am working on. At my website I have multiple processes with
i have implemented code like here but it's not working for iOS 5.0, it
I have a show/hide toggle working well in multiple instances (thanks to help here
I am working on some homework here, but I have completely run out of

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.