facebook apprequest redirecting to domain - PHP SDK

314 views Asked by At

This is my first app in FB. I'm developing a game in Facebook. I'm using PHP-SDK to invite friends to my app.

I could able to send requests and get the to ids as well, but when when i click on send request. I'm getting redirected to my domain.

<a href="invite.php">Invite</a>

this is my invite.php code

<?php
include("config.php");
$reqid = $_GET['request'];
$to = $_GET['to'];

if($reqid==''){
    $message = "Check this great app?";
    $url = CANVAS_URL."invite.php";
    $requests_url = "http://www.facebook.com/dialog/apprequests?app_id=".APP_ID."&redirect_uri=".urlencode($url)."&message=".$message;
    echo("<script> top.location.href='" . $requests_url . "'</script>");
}else{
    echo "Invite Done!";
    echo "Invited ".count($to);
    exit;
}
?>

I get Invite Done! Invited

Why am i redirecting to the domain ??

When i go through http://apps.facebook.com/app-name, I could still able to view the content in the iframe within facebook The Facebook friends list is also with the facebook, but after i send the requests to friends i'm redirected to canval_url given http://domain-name.com

Thanks for the help.

1

There are 1 answers

0
Tiberiu Popescu On

Don't know if this is the correct solution, but it worked for me :

After user login i was redirected back to my domain.com instead of facebook/myapp so...i redirected again back with javascript :)

In HTML file:

<head>
 <script>
   if(window.location.href != 'http://domain.com/game/')
   window.location.href='https://apps.facebook.com/appNAME/';    
    </script>
</head>