Facebook向好友列表中的随机用户发送应用程序邀请

Facebook向好友列表中的随机用户发送应用程序邀请,facebook,facebook-opengraph,facebook-apps,invitation,facebook-app-requests,Facebook,Facebook Opengraph,Facebook Apps,Invitation,Facebook App Requests,我想把我的申请邀请发送给朋友列表中的多个随机人,就像大多数申请一样。 比如说 一旦我接受应用程序,就会出现这个弹出窗口。我无法理解的是如何获取这些用户的ID?在客户端 <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="https://www.facebook.com/2008/fbml"> <head> <title>Request Example</title> <

我想把我的申请邀请发送给朋友列表中的多个随机人,就像大多数申请一样。 比如说

一旦我接受应用程序,就会出现这个弹出窗口。我无法理解的是如何获取这些用户的ID?在客户端

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:fb="https://www.facebook.com/2008/fbml">
  <head>
    <title>Request Example</title>
  </head>

  <body>
    <div id="fb-root"></div>
    <script src="http://connect.facebook.net/en_US/all.js"></script>
    <p>
      <input type="button"
        onclick="sendRequestToRecipients(); return false;"
        value="Send Request to Users Directly"
      />
      <input type="text" value="User ID" name="user_ids" />
      </p>
    <p>
    <input type="button"
      onclick="sendRequestViaMultiFriendSelector(); return false;"
      value="Send Request to Many Users with MFS"
    />
    </p>

    <script>
      FB.init({
        appId  : '423165827708510',
        frictionlessRequests: true,
      });

      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);
      }

      function sendRequestViaMultiFriendSelector() {
        FB.ui({method: 'apprequests',
          message: 'My Great Request'
        }, requestCallback);
      }

      function requestCallback(response) {
        // Handle callback here
      }
    </script>
  </body>
</html>

请求示例

FB.init({ appId:'423165827708510', 无摩擦要求:正确, }); 函数sendRequestToRecipients(){ var user_id=document.getElementsByName(“user_id”)[0]。值; ui({method:'apprequests', 信息:“我伟大的请求”, 收件人:user_ID,///如何在此处填写ID? },请求回调); } 函数sendRequestViaMultiFriendSelector(){ ui({method:'apprequests', 信息:“我伟大的请求” },请求回调); } 函数requestCallback(响应){ //在这里处理回调 }
为什么要发送给随机用户? 那没有任何意义-你肯定会邀请你认为会喜欢这个游戏的人

除了混淆,为了回答您的问题,“to”参数要么是一个数组,要么是一个逗号分隔的用户ID列表

以下是CSV示例,摘自:


-`api('/me/friends',函数(response){响应有一个ID和名称列表,现在如何提取随机ID并将其传递给sendRequestToRecipients()})`将结果随机化;找到如何做到这一点需要几秒钟的时间。我试过了,但它返回了一些复杂的费希尔-耶茨算法,用于随机响应。这不起作用吗//随机排列数组的顺序:
var myarray=[25,8,“George”,“John”]myarray.sort(function(){return 0.5-Math.random()})//数组元素现在被置乱了
FB.api('/me/friends',function(response){var myarray=response;myarray.sort(function(){return 0.5-Math.random()})document getElementsByName(“用户ID”)[0].html=response;console.log('很高兴见到你,+myarray+');正在给我未捕获的类型错误:对象#没有“sort”方法
function sendRequestToRecipients() {
  FB.ui({method: 'apprequests',
    message: 'My Great Request',
    to: '499802820,499802852'
  }, requestCallback);
}