Javascript 如何检查facebook fanpage是否受欢迎
你如何检查访问者是否喜欢facebook的粉丝页面。所以我在代码中填写我的app\u id,page\u id 这是我现在掌握的密码Javascript 如何检查facebook fanpage是否受欢迎,javascript,facebook,api,Javascript,Facebook,Api,你如何检查访问者是否喜欢facebook的粉丝页面。所以我在代码中填写我的app\u id,page\u id 这是我现在掌握的密码 <div id="fb-root"></div> <script src="http://connect.facebook.net/en_US/all.js"></script> <script> FB.init({ appId : 'APP_ID', status : true,
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId : 'APP_ID',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true, // parse XFBML
channelUrl : 'http://domain.com/tab/', // channel.html file
oauth : false // enable OAuth 2.0
});
(function($) {
var session = FB.getSession();
FB.api({
method: 'fql.query',
query: 'SELECT uid, page_id FROM page_fan WHERE uid=me() AND page_id=PAGE_ID'
},
function(response) {
if(response instanceof Array && response.length > 0)
alert("YOU LIKE US!");
else
alert("YOU DON'T LIKE US YET!");
});
})(jQuery);
</script>
FB.getSession方法已被弃用。改用
FB.getAuthResponse
。如果当前用户已经喜欢或不喜欢您的页面,您可以这样处理:
FB.api("me/likes/PAGE_ID", function(response) {
if ( response.data.length == 1 ) { //there should be a single value inside `data` which is your page details
alert('you like us :-)')
} else {
alert('please like our page')
}});
你需要用户喜欢这个
FB.api("me/likes/PAGE_ID", function(response) {
if ( response.data.length == 1 ) { //there should be a single value inside `data` which is your page details
alert('you like us :-)')
} else {
alert('please like our page')
}});