2013-06-26 3 views
0

을 정의 그래서에서 페이스 북 로그인 통합에 대한 자습서를 찾을 수 없습니다페이스 북 로그인 기능

Uncaught TypeError: object is not a function index.php:53 onclick

: http://www.excellencemagentoblog.com/facebook-login-integration-website

을 나는 말을 Facebook Login을 클릭 한 후 나에게 오류를 제공 스텝과 구글의 Chromes 개발자 도구에 의해 단계 다음

버튼의 HTML은 다음과 같이이다 :

<a class="btn btn-success" href='#' onclick='login();'> 
     <i class="icon-facebook"></i> 
     Facebook Login 
</a> 

스크립트는 다음과 같다 s, 나는 함수가 스크립트 내에서 정의 되었기 때문에 무엇이 잘못되었는지를 정말로 알 수 없다. 당신이 여기에서 발생하는 문제도 확인

<script type="text/javascript"> 

    window.fbAsyncInit = function() { 
     FB.init({ 
     appId  : ' 163289720517425', // App ID 
     channelURL : '', // Channel File, not required so leave empty 
     status  : true, // check login status 
     cookie  : true, // enable cookies to allow the server to access the session 
     oauth  : true, // enable OAuth 2.0 
     xfbml  : false // parse XFBML 
     }); 
    }; 
    // logs the user in the application and facebook 
    function login(){ 
    FB.getLoginStatus(function(r){ 
     if(r.status === 'connected'){ 
       window.location.href = 'php/fbconnect.php'; 
     }else{ 
      FB.login(function(response) { 
        if(response.authResponse) { 
        //if (response.perms) 
         window.location.href = 'php/fbconnect.php'; 
       } else { 
        // user is not logged in 
       } 
     },{scope:'email'}); // which data to access from user profile 
    } 
    }); 
    } 
    // Load the SDK Asynchronously 
    (function() { 
     var e = document.createElement('script'); e.async = true; 
     e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';     
     document.getElementById('fb-root').appendChild(e); 
    }()); 
</script> 
+0

PHP SDK를 설치 했습니까? – KyleK

답변

0

없음 .... 내가 경고와 함께 단지 함수에 내려 삶은 경우에도 사촌 .... 그것은 여전히 ​​작동하지 않았다 ???? 의미는 페이스 북과 관련이 없다는 것입니다.

어쨌든 ....이 도메인을 등록 그래서 내가 .... ... .... 당신은 크로스 도메인 요청을하고있는

그것을 할 것이다 어떻게

FB는 자바 스크립트 SDK를 제공하므로 PHP와 Javascript를 모두 사용할 필요가 없습니다. ...

window.fbAsyncInit = function() { 
// init the FB JS SDK 
FB.init({ 
    appId  : '163289720517425',      // App ID from the app dashboard 
    channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel file for x-domain comms!! 
    cookie  : true, // enable cookies to allow the server to access the session 
    oauth  : true, // enable OAuth 2.0 
    status  : true,         // Check Facebook Login status 
    xfbml  : true         // Look for social plugins on the page 
}); 

// Additional initialization code such as adding Event Listeners goes here 

$('.btn-success').click(login); 

}; 

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

function login(){ 
FB.login(function(response) { 
if (response.authResponse) { 
console.log('Welcome! Fetching your information.... '); 
FB.api('/me', function(response) { 
    console.log('Good to see you, ' + response.name + '.'); 
    }); 
} else { 
    console.log('User cancelled login or did not fully authorize.'); 
} 
});} 
+0

좋아, 그게 효과가있는 것처럼 보입니다. 아직 완성되지 않은 것 같아요. 즉 사용자를 대시 보드로 리디렉션하고 자신의 정보를 데이터베이스에 저장합니다. – user2371301

+0

나는 당신이 내릴 때까지 기다릴 거라 생각합니다. – user2371301

+0

좋아, 문제 없지 .... 내가 뭘 할 수 있는지 보겠다. – KyleK