2017-12-05 1 views

답변

0

Facebook JavaScript SDK를 사용하여 수행 할 수 있습니다. 참고 :이 작업은 백엔드가 아닌 프론트 엔드에서 실행됩니다.

document.querySelector('your-btn').addEventListener('click', (e) => { 
    e.preventDefault() 
    FB.login((response) => { 
    // your callback 
    }) 
}) 
: 로그인 버튼에 이벤트 리스너를 추가 할 때 지금

getScript('//connect.facebook.net/en_GB/sdk.js#xfbml=1&version=v2.10&appId=yourappidhere',() => { 
    if(typeof window.fbAsyncInit === 'undefined') { 
    FB.init({ 
     appId: 'you app id', 
     version: 'your app version', 
     status: true, 
     cookie: true, 
     xfbml: true, 
     frictionlessRequests: true, 
     useCachedDialogs: true, 
     oauth: true 
    }) 
    } 
}) 

:

function getScript(u, c) { 
     var h = document.getElementsByTagName('head')[0], s = document.createElement('script') 
     s.async = true 
     s.src = u 
     s.onload = s.onreadystatechange = function() { 
     if (!s.readyState || /loaded|complete/.test(s.readyState)) { 
      s.onload = s.onreadystatechange = null; if (h && s.parentNode) { h.removeChild(s) } s = undefined 
      if (c) { c() } 
     } 
     } 
     h.insertBefore(s, h.firstChild) 
    } 

지금과 같이 FB JS SDK 및 초기화 FB API를 가져 오기