简体   繁体   English

如何处理从Facebook apprequest函数返回的响应?

[英]How to handle the response returned from the facebook apprequest function?

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

      function requestCallback(response) {

      }

apparently its supposed to return something like this 显然它应该返回这样的东西

{
  “request_ids”: [
    0: [request_id]
    1: [request_id]
    ...
  ]
}

i need to get the ids from the response and execute another function using the ids how can i do that? 我需要从响应中获取ID并使用ID执行另一个功能,我该怎么做? thanks in advance 提前致谢

I guess you means ids is the id of recipient ids, so the easiest way is 我想您的意思是ID是收件人ID的ID,所以最简单的方法是

  1. Enable "Request 2.0 Efficient" you can enable it in your application setup page (advance tab) 启用“请求2.0有效”,可以在应用程序设置页面(“高级”标签)中启用它

  2. Use the following: 使用以下内容:

     function requestCallback(response) { var ids = response["to"]; for (var i = 0; i < ids.length; ++i) { //"ids[i]" is what you want. } } 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM