任何人都知道我为什么会收到以下错误:
e.root is undefined in all.js
我不确定这里有什么问题。这是我的代码的相关部分..
<script src="https://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
appId : 'xxxxxxxxxxxxxxxxxx', // App ID
channelURL : 'https://nowfoods.marketspacecom.com/channel.html', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
oauth : true, // enable OAuth 2.0
xfbml : true // parse XFBML
});
// Additional initialization code here
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
</head>
<body>
<a href="javascript:fb_publish();" class="fbshare"><img src="images/share.gif" /></a>
<script type="text/javascript">
//set the height of the canvas
window.fbAsyncInit = function() {
FB.Canvas.setSize({height: 1250});
}
//this function will publish a post to the user's wall
function fb_publish() {
// calling the API ...
var obj = {
method: 'feed',
name: 'Get a free sample of <?php echo $getLatestPromoID['prodName']; ?> from NOW Foods!',
link: '<?php echo $fbconfig['appBaseUrl']; ?>',
picture: 'https://nowfoods.marketspacecom.com/images/nowicon.gif',
caption: 'NOW Foods Free Samples',
description: 'I just signed up for a free sample of NOW Foods <?php echo $getLatestPromoID['prodName']; ?>. You can get one too at the link above!'
};
function callback(response) {
document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
}
FB.ui(obj, callback);
}
</script>
<div id="fb-root"></div>
</body>
XXX X X X XX X XX X XXXXX X XXXX X XXX
XXX X X X XX X XX X XXXXX X XXXX X XXX
XXX X X X XX X XX X XXXXX X XXXX X XXX
XXX X X X XX X XX X XXXXX X XXXX X XXX
XXX X X X XX X XX X XXXXX X XXXX X XXX
答案 0 :(得分:6)
“<div id="fb-root"></div>
”必须在剧本包括之前出现...我想...