Question

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.

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top