2011-02-11 2 views
0

당신은 당신이 얻을 페이스 북 응용 프로그램을 등록 할 때키 페이스 북의 응용 프로그램의 목적은 무엇

응용 프로그램 ID : 123455678 응용 프로그램 키 : hkjhkh3434hkklljk 응용 프로그램 비밀 : jkjljlj1233455jk의 OAuth 2 만 응용 프로그램 ID (일명 CLIENT_ID)에 대한

및 응용 프로그램 비밀 (client_secret라고도 함)은 유용합니다.

응용 프로그램 키의 용도가 궁금하십니까? 일부 백엔드 용도일까요? 그렇다면, 노출 지점은 무엇입니까?

답변

2

큰 소리로 생각하고 있습니다.

이전 버전과의 호환성을 위해, 특히 Facebook Connect 구현과 REST API의 경우 APP_KEY이 사용 된 경우에만 존재합니다.

당신이 FB.init 자바 스크립트 SDK에서 볼 수 있듯이 :

<div id="fb-root"></div> 
<script> 
    window.fbAsyncInit = function() { 
    FB.init({ 
     appId : 'YOUR APP ID', 
     status : true, // check login status 
     cookie : true, // enable cookies to allow the server to access the session 
     xfbml : true // parse XFBML 
    }); 
    }; 

    (function() { 
    var e = document.createElement('script'); 
    e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; 
    e.async = true; 
    document.getElementById('fb-root').appendChild(e); 
    }()); 
</script> 

그들은 NEWPHP-SDK으로 사용되는 코드입니다 apiKey을 언급하지 않습니다.
이제 이전 connect-js example에 가면 :

FB.init({ apiKey: '48f06bc570aaf9ed454699ec4fe416df' }); 

는 그래서 connect.facebook.net/en_US/all.js 파일을 디버깅 ( JSBeautifier 사용) :

FB.provide('', { 
    init: function (a) { 
     a = FB.copy(a || {}, { 
      logging: true, 
      status: true 
     }); 
     FB._apiKey = a.appId || a.apiKey; 
     if (!a.logging && window.location.toString().indexOf('fb_debug=1') < 0) FB._logging = false; 
     FB.XD.init(a.channelUrl); 
     if (FB._apiKey) { 
      FB.Cookie.setEnabled(a.cookie); 
      a.session = a.session || FB.Cookie.load(); 
      FB.Auth.setSession(a.session, a.session ? 'connected' : 'unknown'); 
      if (a.status) FB.getLoginStatus(); 
     } 
     if (a.xfbml) window.setTimeout(function() { 
      if (FB.XFBML) FB.Dom.ready(FB.XFBML.parse); 
     }, 0); 
    } 
}); 

현재 그 다음 apiId 또는 apiKey과의 존재를 확인 있다고 볼 수 있습니다 그래프 api를 호출하려고 시도하고 else 나머지 api :

FB.provide('', { 
    api: function() { 
     if (typeof arguments[0] === 'string') { 
      FB.ApiServer.graph.apply(FB.ApiServer, arguments); 
     } else FB.ApiServer.rest.apply(FB.ApiServer, arguments); 
    } 
}); 

그리고 :

나머지 API 2.0 뿐만 아니라 이전과 같은 양의 OAuth를 지원합니다 : 당신이 여기에서 볼 수 있듯이

graph: function() { 
    var a = Array.prototype.slice.call(arguments), 
     f = a.shift(), 
     d = a.shift(), 
     c, e, b; 
    while (d) { 
     var g = typeof d; 
     if (g === 'string' && !c) { 
      c = d.toLowerCase(); 
     } else if (g === 'function' && !b) { 
      b = d; 
     } else if (g === 'object' && !e) { 
      e = d; 
     } else { 
      FB.log('Invalid argument passed to FB.api(): ' + d); 
      return; 
     } 
     d = a.shift(); 
    } 
    c = c || 'get'; 
    e = e || {}; 
    if (f[0] === '/') f = f.substr(1); 
    if (FB.Array.indexOf(FB.ApiServer.METHODS, c) < 0) { 
     FB.log('Invalid method passed to FB.api(): ' + c); 
     return; 
    } 
    FB.ApiServer.oauthRequest('graph', f, c, e, b); 
}, 
rest: function (e, a) { 
    var c = e.method.toLowerCase().replace('.', '_'); 
    if (FB.Auth && c === 'auth_revokeauthorization') { 
     var d = a; 
     a = function (f) { 
      if (f === true) FB.Auth.setSession(null, 'notConnected'); 
      d && d(f); 
     }; 
    } 
    e.format = 'json-strings'; 
    e.api_key = FB._apiKey; 
    var b = FB.ApiServer._readOnlyCalls[c] ? 'api_read' : 'api'; 
    FB.ApiServer.oauthRequest(b, 'restserver.php', 'get', e, a); 
}, 

, 그것은이 문서를 읽기는 Old Rest API에 사용되는 맞춤 승인 서명 체계. 기존 세션을 OAuth 2.0으로 업그레이드하는 방법에 대한 인증 업그레이드 가이드를 참조하십시오.

는 그래서 APP_KEY은 이전 버전과의 호환성을 위해 확실히있다!

+0

나는 이것이 의미가 있다고 생각하는데, 그것은 이전 버전과의 호환성을위한 것입니다. 로그 아웃을 위해 여전히 애플리케이션 키가 필요하다는 것을 알아 냈습니다. 예를 들어 로그 아웃하려면 'http://www.facebook.com/logout.php?api_key={application key} &; session_key = {oauth 2.0 code}'를 호출하십시오. " ;'_OAuth 2.0_과의 호환성을 위해서'http://www.facebook.com/logout.php?api_id={client_id}&;app_secret={client_secret}&;session_key={oauth 2.0 code};'또는 단순히'http : //www.facebook.co.kr/logout.php? session_key = {oauth 2.0 code};'페이스 북은 OAuth 2.0 구현 측면에서 일관성이없는 것처럼 보입니다. – user613343

+0

@ user613343 : PHP-SDK를 사용하면 ...'$ facebook-> getLogoutUrl()'호출로 생성 된 로그 아웃 URL은 다음과 같이 보입니다 :'https://www.facebook.com/logout.php?next=http : // domain.com/& access_token = XXXXXXXX' – ifaour