我在jQuery中编写了一个执行以下操作的代码:
检查Facebook上是否喜欢并显示内容,如果不喜欢则询问是否喜欢
<script>
$('#loginfb').click( function() {
FB.login(function(response) {
if (response.authResponse) {
var logstatus="logged in";
FB.api('/me', function(response) {
console.log('Good to see you, ' + response.name + '.');
});
$('#loginfb').empty();
$('#loginfb').append('<p>Logged In to Facebook</p>');
console.log('Welcome! Fetching your information.... ');
var url = 'http://facebook.com/bitslabo';
$('#fblikeblock').html('<div id="pleaselike">like!</div><fb:like id="fbLike" href="'+url+'" send="false" layout="button_count" width="450" show_faces="false" font=""></fb:like>');
FB.XFBML.parse(document.getElementById('fblikeblock'));
} else {
console.log('User cancelled login or did not fully authorize.');
}
},{perms:"friends_likes,user_likes"});
});
$('#getlogin').click( function() {
FB.getLoginStatus(function(response) {
var page_id = "[PAGE ID]";
if (response && response.authResponse) {
var user_id = response.authResponse.userID;
var fql_query = "SELECT uid FROM page_fan WHERE page_id = "+page_id+" and uid="+user_id;
FB.Data.query(fql_query).wait(function(rows) {
if (rows.length == 1 && rows[0].uid == user_id) {
console.log("LIKE");
$('#container_notlike').hide();
$('#container_like').show();
} else {
console.log("NO LIKEY");
$('#container_like').hide();
$('#container_notlike').show();
}
});
} else if (response.status === 'not_authorized') {
// the user is logged in to Facebook,
// but has not authenticated your app
alert('Please click "Log in to Facebook"');
} else {
alert('Please click "Log in to Facebook"');
// the user isn't logged in to Facebook.
}
});
});
</script>
问题是我正在使用的CMS(magento 1.5)上面有prototype.js,并且存在jQuery与Prototype冲突,其中jQuery覆盖Prototype并禁用站点的所有功能。
所以,我想,这里有两个问题:
我希望有道理!提前谢谢!