php - facebook redirect


I have a problem when using facebook authentication.

 $user = null;
     include_once "fb/facebook.php";
 catch(Exception $o){
 $facebook = new Facebook(array(
    'appId'  => $fbconfig['appid'],
    'secret' => $fbconfig['secret'],
    'cookie' => true

$loginUrl = $facebook->getLoginUrl(array(
    'scope' => 'publish_stream,email',  
    //'redirect_uri' => ''
$user = $facebook->getUser();
        $user_profile = $facebook->api('/me');
        $permissions = $facebook->api('/me/permissions');                                  
        }catch(FacebookException $e){                   
         echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>";

When the user accepted the app, it will redirect user to tab page(, user wont stay on facebook, but only 1st time will do that if the user close and come back to app on facebook(already authenticated) it works fine in iframe. If I use the redirect_uri => my_app , it will redirect and redirect and redirect but never will work the app, the browser just loading and loanding but nothing happends. I spent days to fix this problem but I could not find any solution. Any idea whats wrong?




Change $loginUrl as below and try:

$_SESSION['state'] = md5(uniqid(rand(), TRUE)); // CSRF protection $loginUrl _url = "" . APP_ID . "&redirect_uri=" . urlencode($next) . "&state=" . $_SESSION['state'] . "&scope=".$permissions;

People are also looking for solutions to the problem: php - mcrypt_crypt and decrypt does result does not match


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.