2011-12-13 2 views
4

아래 오류가 있습니다. 이 오류를 어떻게 잡을 수 있습니까?잡히지 않는 OAuthException -이 에러를 잡는 방법?

Fatal error: Uncaught OAuthException: Error validating access token: User 638720122 has not authorized application 207445576002891. thrown in /var/www/clients/client1/web12/web/socialmediaping/fblibrary/base_facebook.php on line 1039

내가 오류를 관리하려고 할 때 내가 알고있는 코드 스 니펫이 있습니다.

// Attempt to query the graph: 
$graph_url = "https://graph.facebook.com/me?" 
    . "access_token=" . $access_token; 
$response = curl_get_file_contents($graph_url); 
$decoded_response = json_decode($response); 

//Check for errors 
if ($decoded_response->error) { 
    $facebookAuth = FALSE; 
} 

은 또한 아래로 나는 $ facebookAuth가 == FALSE하지만 이러면의 작업, 그래서 내가 뭘해야하는지 authoise하는 페이스 북 사용자를 리디렉션?

도움을 주셔서 미리 감사드립니다.

답변

7

base_facebook.php을 조이지 마십시오! 그래프 주위에 try/catch 블록을 사용하기 만하면됩니다.

try { 

    // check if facebook can get user 
    $facebookUser = $facebook->getUser(); 
    $facebookUser = $facebook->api('me?fields=id,first_name,last_name'); 

} catch (Exception $e) { 
    // user is not logged in 
}