Saad Bashir
Saad Bashir

Reputation: 4519

facebook request_uri not working

The invitation dialog pops up fine and invitation is also sent. But i am unable to redirect the user to desired page after sending the invitation using redirect_uri as stated in Requests Dialog facebook documentation (https://developers.facebook.com/docs/reference/dialogs/requests/). There is no redirection or anything after sending invitation.

<div id="fb-root"></div>
    <script src="http://connect.facebook.net/en_US/all.js"></script>
    <script>
      FB.init({
        appId  : 'app_id',
      });
      function sendRequestViaMultiFriendSelector() {
        FB.ui({method: 'apprequests',
          message: 'Invite friends!',
          request_uri: 'https://apps.facebook.com/myappname/invitesent.php', data: '<?php echo $user_id; ?>', exclude_ids: [<?php echo $friends; ?>]
        }, requestCallback);
      }
      function requestCallback(response) {
        // Handle callback here
      }
    </script>

Upvotes: 0

Views: 2141

Answers (3)

Tousif Jamadar
Tousif Jamadar

Reputation: 141

As you have already included Facebook javascript SDK in your App and you have writen this code for inviting friend for your App in a script

 FB.ui({ method: 'apprequests',
        redirect_uri: 'APP URL',   
         message: 'My Message' 
    });

This will redirect to App URL without redirecting to Facebook canvas URL.So this will not work even if you use data parameter such as

FB.ui({ method: 'apprequests',
    data: 'APP URL',   
     message: 'My Message' 
});

Write this code at your App landing page i.e. in index.php at beginning of the code.

$requestid=$_GET[request_ids];    
if(!empty($requestid))
    {       
        echo "<script> window.top.location.href='APP URL'; </script>";                
    }

Upvotes: 1

ifaour
ifaour

Reputation: 38115

You don't need the redirect_uri if you are using the JS-SDK. This is the job of the callback function, so in your requestCallback():

function requestCallback(response) {
    // Handle callback here
    ...


    // once done, redirect (outside of Facebook page!)
    top.location.href = 'http://mydomain.com/nextpage/';
}

Or I suppose location.href = ''; to stay in the Facebook app frame.

Upvotes: 1

Joe
Joe

Reputation: 4512

Have you given callback canvas url when you create facebook application?

Upvotes: 0

Related Questions