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

倾然丶 夕夏残阳落幕 提交于 2019-12-20 03:23:26

问题


I would like to encourage my facebook app users to invite more friends to join the app. Therefore, I will let them freely use my app after they invite more than 50 friends (no matter their friends join the app or not is also ok).

But the problem is: how can I check the number of invitation sent by that users?

Thanks.

Rgds


回答1:


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




回答2:


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>


来源:https://stackoverflow.com/questions/6772148/how-to-check-number-of-facebook-app-invitation-sent-by-a-particular-users

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!