1

我正在使用 PHP SDK,我现在只是在测试它,看起来 getUser 在登录后返回 0。一直在阅读文档,似乎找不到任何东西。下面是我的用户登录后重定向到的页面。

<?php

require_once("facebook.php");
$facebook = new Facebook(array('appId' => ???,
                             'secret' => '???'));
$uid = $facebook->getUser;
    if($uid){
    try{
        $user_profile = $facebook->api('/me','GET');
        $params = (array('next' => 'http://fbtest.net23.net/'));
        $logouturl = $facebook->getLogoutUrl($params);
        $message = "<p>You ARE loged in with Facebook :)</p>\n";
        $a = "<a href=\"{$logouturl}\">Logout</a>\n";
        $content = $message . "<br/>\n" . $a;
}
 catch (FacebookApiException $e){
     error_log($e);
     $content = "<p>Dont work!</p>\n";
 }
}
else{
      $params = (array('scope' => 'read_stream, friends_likes'));
      $loginurl = $facebook->getLoginUrl($params);
      $message = "<p>You are NOT loged in with Facebook :(</p>\n";
      $a = "<a href=\"{$loginurl}\">Login with FB</a>\n";
      $content = $message . "<br/>" . $a;
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en">
<head>
<title>test</title>
</head>
<body> 

    <?php echo $content;?>

</body>
</html>

问题是在用户登录后,他们得到了 else 语句的结果。任何帮助或建议将不胜感激:)。

4

1 回答 1

0

()失踪...

$uid = $facebook->getUser();
于 2012-04-05T10:53:11.263 回答