2011-09-27 2 views
0

안녕하세요 사용자의 벽에 게시하려고하지만 다음 오류가 발생합니다. 잡히지 않은 OAuthException : 현재 액세스 토큰은 현재 사용자에 대한 정보를 쿼리하는 데 사용해야합니다. 던져 ....Facebook App Uncaught OAuthException : 현재 사용자에 대한 정보를 쿼리하는 데 활성 액세스 토큰을 사용해야합니다. 던졌습니다

내 페이스 북의 스크립트는 다음과 같습니다

$appId = 'xxxxxx'; //change as necessary 
$appUrl = "xxxxx"; //change as necessary 
$baseUrl = "xxxxx/"; //change as necessary 
// Create our Application instance. 
$facebook = new Facebook(array(
    'appId' => $appId, 
    'secret' => 'xxxxxx', //change as necessary 
    'cookie' => true, 
)); 
$session = $facebook->getSession(); 
$fbme = null; 
// Session based graph API call. 
if (!$session) 
{ 
    $login_url = $facebook->getLoginUrl 
    (
    array 
     (
     "canvas" => true, 
     "fbconnect" => false, 
     "req_perms" => "user_location, email, publish_stream, friends_about_me, offline_access,", 
    ) 
    ); 
    echo "<script type='text/javascript'>top.location.href = '" . $login_url. "';</script>"; 
} 
$session = $facebook->getSession(); 
$me = null; 
// Session based API call. 
if ($session) { 
try { 
    $uid = $facebook->getUser(); 
    $me = $facebook->api('/me'); 
    $mail=$me[email]; 
    } catch (FacebookApiException $e) { 
    error_log($e); 
    } 

} 

$signed_request = $_REQUEST["signed_request"]; 
list($encoded_sig, $payload) = explode('.', $signed_request, 2); 
    $data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true); 
    $token=$data[oauth_token]; 
    $attachment = array('message' => '', 
     'access_token' =>$token, 
     'name' => '', 
     'caption' => "", 
     'link' => '', 
     'description' => '', 
     'picture' => '', 
     'actions' => array(array('name' => 'Get Social', 
             'link' => '')) 
    ); 


$result = $facebook->api('me/feed','post',$attachment); 

어떻게 사용자가 토큰에 액세스 할 수 있습니까?

답변

1

열기 이것은 브라우저에서 :

https://graph.facebook.com/oauth/authorize? 
    type=user_agent& 
    client_id=[APP ID]& 
    redirect_uri=http%3A%2F%2Fxyz.com& 
    scope=user_photos,email,user_birthday,user_online_presence 

당신은로 연결됩니다 :

http://xyz.com/#access_token=[ACCESS TOKEN]. 

그리고 당신은 당신의 액세스 토큰을 가지고, 당신은 가서 그것을 사용할 수 있습니다

https://graph.facebook.com/me?access_token= 
    [ACCESS TOKEN] 
관련 문제