简体   繁体   中英

facebook->getUser return null with nginx

I'm use nginx as a Reverse Proxy:

location /facebook/
{

    proxy_pass  http://upload  #this is an nother server;
    proxy_redirect off;
}

and my code:

$facebook = new Facebook(array(
 'appId'  => "xx", 
 'secret' => "xxxxxxxx", 
));


$user = $facebook->getUser();


if ($user){
    $user_profile = $facebook->api('/me');
    var_dump($user_profile);
}

else
{

    $url=$facebook->getLoginUrl( array( 'scope' => $req_perms) );
    //if I used nginx I must change redirect_uri 
    $url = str_replace('http%3A%2F%2Fupload%2F', 'http%3A%2F%2F'. $mydomian .'%2F',$url);
    header("Location:".$url);
}

If I do not use nginx as Reverse Proxy,it works fine, but if I use it, it creates an endless loop because $facebook->getUser() returns 0. I have no idea what the problem is.

您登录的URL必须与开发人员应用程序https://developers.facebook.com/apps/YOUR_APP_ID/summary中的选择您的应用程序如何与Facebook集成 ”下设置的URL匹配,否则将无法使用。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM