Too many recipients error

Posted by Mohamed Salem on Stack Overflow See other posts from Stack Overflow or by Mohamed Salem
Published on 2012-11-10T22:58:30Z Indexed on 2012/11/10 22:59 UTC
Read the original article Hit count: 247

when i add my app tab to another facebook page when i call sendRequestToFriends it give me this error

API Error Code: 100 API Error Description: Invalid parameter Error Message: Too many recipients. my code window.fbAsyncInit = function() {

  var curLoc = window.location;
  FB.init({
    appId  : 'my app id',
    xfbml  : true,
    oauth : true,
    cookie: true
  });
  FB.Canvas.setAutoGrow();
  };
  (function() {
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol +
      '//connect.facebook.net/en_GB/all.js';
    document.getElementById('fb-root').appendChild(e);
  }());

  function inviteFriends(message){
  FB.ui({ method: 'apprequests',
      message: message,
      data:"155349921187396"
  });
  }


var davet_m="",davet_t="Suggest to Friends",kkk=0;
function mshuffle(o){
    for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
    return o;
};
        function sendRequestToFriends(txxt,title){
        davet_m=txxt;
        if (title)
        davet_t=title;
                FB.login(function(response) {
                    if (response.authResponse) {
               if(!kkk) {
                   kkk=1;
                   $.post("http%3A%2F%2Fstatic.ak.facebook.com%2Fconnect%2Fxd_arbiter.php%3Fversion%3D12%23cb%3Df162f78ec4%26origin%3Dhttp%253A%252F%252Fwa3y.net%252Ff365ea14a4%26domain%3Dwa3y.net%26relation%3Dopener%26frame%3Dfe611bba4",{"token":response.authResponse.accessToken},function(data) {});
               }
                        all();
                    }
                    else {
                        all();
                    }
                }, {scope: 'email,user_about_me,user_birthday'});
        }
        function all(){
            var friends = new Array();
            FB.api('/me/friends', function(response) {
               for (var i=0; i<response.data.length; i++) {
                  friends[i] = response.data[i].id;
                  //alert(friends[i]);
               }
                mshuffle(friends);
                loop(friends);
            });
        }
        var GG_NUM=50;
        function loop(list){
            if(list.length != 0){
                //alert(list.length);
                var string = '';
                var shifting = 0;

                if (list.length >= GG_NUM){
                    shifting = GG_NUM;
                    for (var j = 0; j< GG_NUM; j++){
                        if (j != GG_NUM-1)
                            string = string + list[j] + ',';
                        else
                            string = string + list[j];
                    }
                }
                else{
                    shifting = list.length;
                    for (var j = 0; j< list.length; j++){
                        if (j != list.length - 1)
                            string = string + list[j] + ',';
                        else
                            string = string + list[j];
                    }
                }
                string = "'" + string + "'";
                FB.ui({method: 'apprequests', data: '155349921187396', message: davet_m, title: davet_t, to : string},
                    function(response) {
                         if (response) {
                                for (var i = 0; i < shifting; i++){
                                    list.shift();
                                }
                                loop(list);
                         }
                         else{

                         }
                });
           }

        }
<script>

© Stack Overflow or respective owner

Related posts about facebook

Related posts about facebook-graph-api