이렇게 잘 작동합니다 ...하지만 페이지를 두 번 새로 고치거나이 스크립트를 포함하는 두 페이지를 클릭하면 빨리) 그것은이 오류를 제공합니다 OAuthException : 현재 사용자에 대한 정보를 쿼리하는 데 활성 액세스 토큰을 사용해야합니다. 아이디어가 있으십니까?같은 facebook 문제 ... OAuthException : 현재 사용자에 대한 정보를 쿼리하는 데 활성 액세스 토큰을 사용해야합니다
<?php
$app_id = '***************';
$app_secret = '**************';
$app_namespace = '****************';
$app_url = 'http://apps.facebook.com/' . $app_namespace . '/';
$scope = 'email,publish_actions';
// Init the Facebook SDK
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
));
// Get the current user
$user = $facebook->getUser();
// If the user has not installed the app, redirect them to the Login Dialog
if (!$user) {
$loginUrl = $facebook->getLoginUrl(array(
'scope' => $scope,
'redirect_uri' => $app_url,
));
print('<script> top.location.href=\'' . $loginUrl . '\'</script>');
}
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me', 'POST');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
//<img src="https://graph.facebook.com/?php echo $user; ?/picture">
//?php print_r($user_profile); ?
?>