次のコードで JavaScript エラーが発生します。私が得ているエラーは「Uncaught ReferenceError: FB is not defined. postToFeed (anonymous function)」です。誰かがこれで私を助けることができますか? 前もって感謝します。
window.fbAsyncInit = function() {
FB.init({
appId : '<?= APP_ID ?>', // App ID
channelUrl : '.....', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
// Additional initialization code here
};
// Load the SDK Asynchronously
(function(d){
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.js";
ref.parentNode.insertBefore(js, ref);
}(document));
function postToFeed() {
var obj = {
method: 'feed',
link: '<?= REDIRECT_URL ?>',
picture: '<?= SHARE_IMAGE ?>',
name: unescape('<?= SHARE_TITLE ?>'),
caption: unescape('<?= SHARE_CAPTION ?>'),
description: unescape('<?= SHARE_DESCRIPTION ?>')
};
function callback(response) {
console.log(response);
//alert("Message posted to your wall, thanks!");
if (response && response.post_id) {
alert('Success');
window.location="page.php";
} else {
alert('Fail.');
}
}
FB.ui(obj, callback);
}
function sendToFriend() {
var obj = {
method: 'send',
link: '<?= REDIRECT_URL ?>',
picture: '<?= SHARE_IMAGE ?>',
name: unescape('<?= SHARE_TITLE ?>'),
caption: unescape('<?= SHARE_CAPTION ?>'),
description: unescape('<?= SHARE_DESCRIPTION ?>')
};
function callback(response) {
console.log(response);
//alert("Message sent to your friend(s), thanks!");
if (response && response.post_id) {
alert("Success!");
window.location="page.php";
} else {
alert('Fail.');
}
}
FB.ui(obj, callback);
}