Tôi đang cố triển khai tính năng ủy quyền bằng cách sử dụng SDK JavaScript của Facebook. Khi tôi chạy nó, nó và kiểm tra giao diện điều khiển tôi thấy lỗi.SDK Javascript của Facebook không được khai báo Loại lỗi: Không thể đọc thuộc tính 'userID' không xác định
uncaught TypeError: Cannot read property 'userID' of undefined
Mã đoạn mã
<div id="fb-root"></div>
<!-- Load the Facebook JavaScript SDK -->
<script src="//connect.facebook.net/en_US/all.js"></script>
<script>
var appId = 'APP_ID';
var uid;
// Initialize the JS SDK
FB.init({
appId: '413026618765431',
cookie: true,
});
// Get the user's UID
FB.getLoginStatus(function(response) {
uid = response.authResponse.userID ? response.authResponse.userID : null;
});
function authUser() {
FB.login(function(response) {
uid = response.authResponse.userID ? response.authResponse.userID : null;
}, {scope:'email,publish_actions'});
}
</script>