我对 Facebook PHP API 有疑问。这是我的代码:
<?php
$facebook = new Facebook(array(
'appId' => 'MY_APP_ID',
'secret' => 'MY_SECRET'
));
$uid = $facebook->getUser();
if ($uid) {
try{
$user = $facebook->api('/me');
} catch (Exception $e){
error_log($e);
$user = null;
}
}
if (!$uid) {
$login_url = $facebook->getLoginUrl(array(
'next' => 'http://www/mywebsite.com',
'redirect_uri' => 'http://www/mywebsite.com',
'scope' => 'email,publish_stream,user_birthday,user_location'
));
echo '<a href="'.$login_url.'">TEST TO CONNECT</a>';
} else {
print_r($user);
}
我一直有 TEST TO CONNECT 行,所以它看起来像 $facebook->getUser(); 总是返回 0。有什么想法吗?
谢谢您的帮助