0

페이스 북의 액세스 토큰을 얻고 싶습니다. 페이스 북 개발자 웹 사이트에서이 코드를 얻었지만 액세스 토큰을 생성하거나 제공 할 수 없습니다. 내 웹 사이트가 아닌 간단한 텍스트 파일에서이 코드를 사용합니다.페이스 북의 JavaScript SDK

<div id="fb-root"></div> 
<script> 
<div class="fb-login-button" data-show-faces="true" data-width="400" data-max-rows="1"></div> 
    window.fbAsyncInit = function() { 
    FB.init({ 
     appId  : '377263832388887', // App ID 
     status  : true, // check login status 
     cookie  : true, // enable cookies to allow the server to access the session 
     xfbml  : true // parse XFBML 
    }); 
FB.Event.subscribe('auth.authResponseChange', function(response) { 
    if (response.status === 'connected') { 
     // the user is logged in and has authenticated your 
     // app, and response.authResponse supplies 
     // the user's ID, a valid access token, a signed 
     // request, and the time the access token 
     // and signed request each expire 
     var uid = response.authResponse.userID; 
     var accessToken = response.authResponse.accessToken; 

     // TODO: Handle the access token 

    } else if (response.status === 'not_authorized') { 
     // the user is logged in to Facebook, 
     // but has not authenticated your app 
    } else { 
     // the user isn't logged in to Facebook. 
    } 
    }; 

    // Load the SDK Asynchronously 
    (function(d){ 
    var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0]; 
    if (d.getElementById(id)) {return;} 
    js = d.createElement('script'); js.id = id; js.async = true; 
    js.src = "//connect.facebook.net/en_US/all.js"; 
    ref.parentNode.insertBefore(js, ref); 
    }(document)); 
}); 
</script> 

나는 내 작업을 계속 진행할 수 있도록 액세스 토큰을 얻고 싶습니다. 고맙습니다.

+0

실제로 사용자에게 앱 인증을 요청 하시겠습니까? 그것 없이는 액세스 토큰을 얻을 수 없습니다. –

답변

0

는 다음과 FB.Event.subscribe 기능을 대체 http://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus/

에서 제공하는이 코드를 사용하는 것이 좋습니다.

FB.getLoginStatus(function(response) { 
    if (response.status === 'connected') { 
    var uid = response.authResponse.userID; 
    var accessToken = response.authResponse.accessToken; 

    // dump success data here, and dump response data if needed 

    } else if (response.status === 'not_authorized') { 

    // dump fail data here 

    } else { 
    // dump other fail data here 
    } 
    }); 

나는 FB.Event.subscribe 또한 그 결과 배열에 액세스 코드를 가져야한다고 http://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/에서 볼 수 있지만. 결과를보기 위해 콘솔에 '응답'을 덤핑 해 보셨습니까?

+0

나는 응용 프로그램을 만들거나 C#을 통해이 상태를 크롤링하고 싶습니다. 액세스 토큰이 필요합니다. 액세스 토큰에 대해서는 javathon SDK에서 코드해야합니다. –

+0

이 함수는 Javascript SDK의 일부이기도합니다 . 당신이 돌아 오는 것을보기 위해 '응답'을 버리려고 했습니까? 나는 미안하지만 C# 당신을 도울 수 없다. 아마도 C# 태그를 질문에 추가하면 다른 사람이 도움을 줄 수 있습니다. 서버 측을 인증 할 가능성이 있습니다. – NappingRabbit

+0

자바 스크립트 SDK 만 처리하는 액세스 코드가 필요하고이 코드 웹 브라우저를 실행할 때 아무 것도 반환하지 않습니다. –

관련 문제