2

我使用 nginx 作为反向代理:

location /facebook/
{

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

和我的代码:

$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);
}

如果我不使用 nginx 作为反向代理,它工作正常,但如果我使用它,它会创建一个无限循环,因为$facebook->getUser()返回 0。我不知道问题是什么。

4

1 回答 1

0

您登录的 URL 必须与开发者应用程序https://developers.facebook.com/apps/YOUR_APP_ID/summary在“选择您的应用程序如何与 Facebook 集成”下设置的 URL 匹配,否则它将无法工作.

于 2012-11-08T09:47:20.317 回答