0

I'm trying inviting facebook friends to our application since from 2 days. Still not yet got the solution. I have tried the following code and its sending request to friends but those are not getting any timeline or notification or anything.

<ul id="fcbklist">
    <?php foreach($facebook_friends as $key => $friend): ?>
        <li> <img src="https://graph.facebook.com/<?php echo $key; ?>/picture"/><strong><?php echo $friend;?></strong><br />
             <input type="checkbox" name="friendids[]" class="checkbox" value="<?php echo $key;?>" />
        </li>
    <?php endforeach; ?>
</ul>

<div id="fb-root"></div>
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript">

        FB.init({
            appId  : '259234574212521',
            frictionlessRequests: true
        });

      function sendRequestToRecipients() {
        var ids = [];
        $('.checkbox').each(function() {
            if($(this).is(':checked')) {
                ids.push($(this).val());
            }
        })
        alert(ids);
        var user_ids = ids;
        FB.ui({method: 'apprequests',
          message: 'Request to StoryTag',
          to: user_ids
        }, requestCallback);
      }

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

      function requestCallback(response) {
        // Handle callback here
        if(response){
            ///SUCCESS HERE
            alert('successful');
        } else {
            ///FALIURE COMES HERE
            alert('failure');
        }
      }
    </script>

Please help me get rid of it. The work is more appreciated.

Sanganabasu
  • 943
  • 7
  • 21
  • 39

1 Answers1

1

Paremeter "to" of apprequest should be a String, not an Array, so you need to change var user_ids = ids; to var user_ids = ids.join(',');

Documentation: http://developers.facebook.com/docs/reference/dialogs/requests/#direct_request

  • I did that but still they are not getting anything. – Sanganabasu Apr 04 '13 at 09:11
  • So, if requests are sent normally, but targeted users don't see them, then may be the problem is that your app in "Sandbox Mode"? There is a radio button in "Basic" settings of your app in dashboard. If you don't want to disable sandbox mode, then you should add this friends as testers/developers in "Developers Roles" section of settings. – Marat Gilyazov Apr 04 '13 at 10:15
  • Marat Gilyazov: Hey thanks i got it working now. Would you suggest me to send messages to selected users?. According facebook javascript sdk we can only send message to only one user at a time. – Sanganabasu Apr 04 '13 at 11:26