1

当我调用 sendRequestToFriends 时将我的应用程序选项卡添加到另一个 Facebook 页面时,它给了我这个错误,如果用户的朋友很少,则未显示错误

API 错误代码:100 API 错误描述:无效参数错误消息:收件人太多。

我的代码

<script>
    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>
4

0 回答 0