我在cshtml文件中有一个脚本使用Facebook API,但是未调用函数window.fbAsyncInit。我怎么称呼这个功能?
此功能在控制台中显示“标志1”,但标志2不显示
<div onclick="likeb()">1</div>
function likeb() {
console.log("flag 1");
window.fbAsyncInit = function () {
FB.init({
appId: '295590887998480',
cookie: true,
xfbml: true,
version: 'v3.3'
});
FB.getLoginStatus(function (response) {
statusChangeCallback(response);
});
FB.login(function (response) {
if (response.authResponse) {
console.log('Welcome! Fetching your information.... ');
} else {
console.log('User cancelled login or did not fully authorize.');
}
}, { scope: 'user_likes,user_photos,user_link,user_posts,user_friends,publish_to_groups,manage_pages' });
FB.login(function (response) {
FB.api(
'/me/feed', 'post',
{ "message": "Hé lô mấy bạn ;)" },
function (response) {
console.log(response);
}
);
}, { scope: 'user_likes,user_photos,user_link,user_posts,user_friends,publish_to_groups,manage_pages' });
console.log("flag 2");
};
(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 = "https://connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function statusChangeCallback(response) {
if (response.status === 'connected') {
console.log('Logged in and authenticated');
} else {
console.log('Not authenticated');
}
}
}
此功能在控制台中显示“标志1”,但标志2不显示