Facebook-SDK:未捕获TypeError:对象不是函数

时间:2014-08-06 13:14:45

标签: javascript facebook facebook-graph-api

我正在开发facebook应用程序,我收到了这个错误......

我创建了连接到facebook的脚本文件和加载脚本。问题是我收到了这些错误:

Uncaught TypeError: object is not a function: connect.facebook.net/en_US/sdk.js
Uncaught TypeError: Cannot read property 'offsetTop' of null:connect.facebook.net/en_US/sdk.js

我不知道问题出在哪里...... 这是我用于facebook API的代码(脚本):

function facebookLogin() {
    FB.login(function(response) {
        if (response.authResponse) {
            console.log('Authenticated!');
            FillInfo();
        } else {
            console.log('User cancelled login or did not fully authorize.');
        }
    },
    {
        scope: 'public_profile,email,user_friends'
    });
}
  function statusChangeCallback(response) {
    if (response.status === 'connected') {
      // Logged into your app and Facebook.
      FillInfo();
    } else if (response.status === 'not_authorized') {
    window.top.location("www.facebook.com")
    } else {
      // The person is not logged into Facebook, so we're not sure if
      // they are logged into this app or not.
    facebookLogin();
  }

  function checkLoginState() {
    FB.getLoginStatus(function(response) {
      statusChangeCallback(response);
    });
  }

  window.fbAsyncInit = function() {
  FB.init({
    appId      : '1472957279611934',
    cookie     : true,  // enable cookies to allow the server to access 
    xfbml      : true,  // parse social plugins on this page
    version    : 'v2.0' // use version 2.0
  });
        FB.Canvas.setAutoGrow(100);
   //   FB.Canvas.setAutoResize(100);
 if (typeof FillInfo == 'function') {
        FillInfo();
    }

  FB.getLoginStatus(function(response) {
    statusChangeCallback(response);
  });

  };

  // 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/sdk.js";
    fjs.parentNode.insertBefore(js, fjs);
  }(document, 'script', 'facebook-jssdk'));



  function FillInfo() {
    FB.api('/me', function(response) {
    document.getElementById('name').innerHTML = ' '+response.name;
  }

0 个答案:

没有答案