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 8011663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:05:09+00:00 2026-06-04T19:05:09+00:00

I want to send the App req to 5 people , i have managed

  • 0

I want to send the App req to 5 people , i have managed to get the UserID’s of 5 people but its always those same 5 people , isnt there a way to randomise the USERID's which i get from Facebook ?

<script>
var profilePicsDiv = document.getElementById('profile_pics');

FB.getLoginStatus(function(response) {


  FB.api({ method: 'friends.get' }, function(result) {
    Log.info('friends.get response', result);
   var user_ids="" ;
    var numFriends = result ? Math.min(5, result.length) : 0;
    if (numFriends > 0) {
      for (var i=0; i<numFriends; i++) {
        user_ids+= (

                          ',' + result[i] 

        );
      }
    }
    profilePicsDiv.innerHTML = user_ids;
alert(user_ids);

  });
});


 function sendRequestToRecipients() {
        var user_ids = document.getElementsByName("user_ids")[0].value;
        FB.ui({method: 'apprequests',
          message: 'My Great Request',
          to: user_ids,                        ///  How to Fill the ID's HERE ?
        }, requestCallback);
      }


</script>
  • 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-06-04T19:05:10+00:00Added an answer on June 4, 2026 at 7:05 pm

    I havent tested, but this should work,

    FB.getLoginStatus(function(response) {
     FB.api({ method: 'friends.get' }, function(result) {
       Log.info('friends.get response', result);
       var user_ids="" ;
       var totalFriends = result.length;
       var numFriends = result ? Math.min(5, result.length) : 0;
       if (numFriends > 0) {
          for (var i=0; i<numFriends; i++) {
            var randNo = Math.floor(Math.random() * totalFriends)
            user_ids+= (',' + result[randNo]);
          }
        }
        profilePicsDiv.innerHTML = user_ids;
    alert(user_ids);
    
      });
    });
    

    Here, in loop I generate a random no from 0 to result.length (i.e. total friends in current response) And then I use that random no to fetch random id from the given list.

    Edit: (after OP asked about non-repeating randoms),

    Based on your requirement, this should work…

       FB.getLoginStatus(function(response) {
         FB.api({ method: 'friends.get' }, function(result) {
           Log.info('friends.get response', result);
           var user_ids="" ;
           var totalFriends = result.length;
           var randNo = Math.floor(Math.random() * totalFriends);
           var numFriends = result ? Math.min(5,totalFriends) : 0;
           if (numFriends > 0) {
              for (var i=0; i<numFriends; i++) { 
                user_ids+= (',' + result[randNo]);
                randNo ++;
                if(randNo >= totalFriends){
                    randNo = 0;
                } 
              }
            }
            profilePicsDiv.innerHTML = user_ids;
        alert(user_ids);
    
          });
        });
    

    Here, instead of generating random no each time, I generate a random no once and then increment it. If random no exceeds the total no of friends, then I start from 0.

    This will always give random friends each time 🙂

    Code is not tested, I apologize if has errors ( But code surely gives you a direction to think)

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

Sidebar

Related Questions

So, I have the setup like this (in Express): app.get('/mycall1', function(req,res) { res.send('Good'); });
As per client requirement i want to send crash Report when App get crash.
I have an app where we want users to be able to send us
I want to send a call to lets say www.test.com/updateMySqlTables.php from my app but
I have some image data (jpeg) I want to send from my iPhone app
I have a pretty simple Rails app and I want send an e-mail when
I want to create a PHP app that can send text messages ; There
I want send a email by Email Class in codeigniter with gmail, but i
I want to send an App link within the App like this: http://itunes.apple.com/app/myiphoenapp/id373185673 The
I want send an image from my App to web service, to do it,

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.