我从https://github.com/facebook/facebook-php-sdk下载了 php-sdk ,我参考了 example.php 并将代码复制到我的 php 脚本中。
require_once("class/facebook.php");
$facebook = new Facebook(array(
'appId' => '505646406XXXXX',
'secret' => '4e9b16ac2d072c03426fcdXXXXXXX',
));
// Get User ID
$user = $facebook->getUser();
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
if ($user) {
$logoutUrl = $facebook->getLogoutUrl();
} else {
$loginUrl = $facebook->getLoginUrl();
}
echo $loginUrl;
但是 $loginUrl 是空的。为什么?有人能帮我吗?谢谢!!