2012-06-01 45 views

回答

0

您應該在加載頁面幾秒後添加javascript超時函數以調用Facebook。例如。

setTimeout(function() { 
    FB.getLoginStatus(function(response) { 
     if (response.status === 'connected') { 
      // publish action to facebook 
      FB.api('/me/news.reads', 'post', { article : 'http://www.yourdomain.com/your_article/' }); 
     } else if (response.status === 'not_authorized') { 
      // the user is logged in to Facebook, 
      // but has not authenticated your app 
     } else { 
      // the user isn't logged in to Facebook. 
     } 
    }); 
}, 2000); 

這將允許Facebook SDK有足夠的時間加載和初始化,然後再將您的動作發佈到Facebook。

相關問題