How to check number of facebook app invitation sent by a particular users?

强颜欢笑 提交于 2019-12-02 00:50:54

there is no built in option in facebook for this.

I'm using the FB request dialog and whenever we send request facebook will return a set of request id's (in case of multiple simultaneous requests) .

And then just have your own table say 'tbl_requests' where you can update the current user_id with the request_id returned by the facebook dialog.. The advantage is that you can then backtrack these request_ids when the invited person accepts his invitation.

the sample code could be,

function invite(){
var receiverUserIds = FB.ui({ 
 method : 'apprequests',
 message: 'just a invite msg'
 title: 'Select your friends to join the app',
},
function(receiverUserIds) {
 if(receiverUserIds){  
  $.ajax({
       type: "POST",
       url: "your_file.php",
       req_ids="+receiverUserIds.request_ids,
  });
 }
}
);                 
}

In your_file.php process your request_ids and store them on db and then whenever you want to count the no of request sent you can just query with the current user_id

just change your app 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  : 'YOUR_APP_ID',
        frictionlessRequests: true,
      });

      function sendRequestToRecipients() {
        var user_ids = document.getElementsByName("user_ids")[0].value;
        FB.ui({method: 'apprequests',
          message: 'My Great Request',
          to: user_ids, 
        }, requestCallback);
      }

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

      function requestCallback(response) {
        console.log(response);
        for (var i = 0; i < response.to.length; ++i)
        {
        alert(response.to[i]);
        }
  }
    </script>
  </body>
</html>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!