このエラーはfacebook jsファイルの安全でない読み込みのために発生しています。
Facebookアプリケーションをアプリケーションに統合するには、Facebookアプリケーションのドキュメントに記載されている手順に従わなければなりません。
var fbApi = {
init: function() {
$.getScript(document.location.protocol + '//connect.facebook.net/en_US/all.js', function() {
if (window.FB) {
window.FB.init({
appId: MY_APP_ID,
status: true,
cookie: true,
xfbml: false,
oauth: true,
channelUrl: 'http://www.yourdomain.com/channel.html'
});
}
});
},
login: function() {
/// <summary>
/// Login facebook button clicked
/// </summary>
log("login facebook button clicked");
if (window.FB) {
//Windows phone does not enter this method, Android and Iphone do
window.FB.login(function (response) {
if (response.status) {
log('it means the user has allowed to communicate with facebook');
fbAccessToken = response.authResponse.accessToken;
window.FB.api('/me', function (response) {
//get information of the facebook user.
loginService.subscribeSocialUser(response.id, response.first_name, response.last_name, fbAccessToken, "", "FaceBook", fbSucces, fbFail);
});
} else {
log('User cancelled login or did not fully authorize.');
}
},
{ scope: 'email'
});
}
}
};
クロスブラウザの問題を解決するために、チャンネルURLが追加されています。 Facebook.jsの初期化中にエラーがヒットされた後、あなたが正常にログインできない場合
<script src="//connect.facebook.net/en_US/all.js"></script>
: それは次のようにJSを参照するHTMLファイルを指す必要があります。
Javaスクリプトを同期または非同期でロードできます。
(function(d, debug){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all" + (debug ? "/debug" : "") + ".js";
ref.parentNode.insertBefore(js, ref);
}(document, /*debug*/ false));
ありがとうございます。FBのPHPリダイレクトオプションを使用して実装しました。 –