0

我尝试阅读有关此错误的所有信息,但没有任何帮助:( $facebook->getUser() 始终返回 0 (sdk 3.2)。也许有人可以告诉我我到底需要搜索什么...

代码是任何(示例):

<?php

require 'php-sdk/facebook.php';

$facebook = new Facebook(array(
  'appId'  => 'APP_ID',
  'secret' => 'APP_SECRET',
));

?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>Facebook PHP</title>
</head>
<body>
<h1>Hello World</h1>
<?php
    //get user from facebook
    $user = $facebook->getUser();

    if ($user):
        echo "<p>User ID: $user</p>";
    else:
        $loginUrl = $facebook->getLoginUrl(array(
            'scope' => 'user_birthday,read_stream',
            'redirect_uri'=>'https://apps.facebook.com/myapp'
        ));
        echo '<p><a href="', $loginUrl, '" target="_top">login</a></p>';
    endif;

 ?>
</body>
</html>
4

0 回答 0