gpt4 book ai didi

javascript facebook 检查用户是否是页面的粉丝

转载 作者:行者123 更新时间:2023-11-30 07:25:53 25 4
gpt4 key购买 nike

这是我的代码:

    <div id="fb-root"></div>

<script>
window.fbAsyncInit = function() {
// init the FB JS SDK
FB.init({
appId : '', // App ID from the app dashboard
channelUrl : 'http://.php', // Channel file for x-domain comms
status : true, // Check Facebook Login status
xfbml : true // Look for social plugins on the page
});

// Additional initialization code such as adding Event Listeners goes here
FB.api('me/likes/',function(response) {
if( response.data ) {
if( !isEmpty(response.data) )
alert('You are a fan!');
else
alert('Not a fan!');
} else {
alert(response);
alert('ERROR!');
}
});
};

// Load the SDK asynchronously
(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 = "//connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));



// function to check for an empty object
function isEmpty(obj) {
for(var prop in obj) {
if(obj.hasOwnProperty(prop))
return false;
}

return true;
}
</script>

但是我返回了错误字符串...我做错了什么?

最佳答案

要了解用户是否是该页面的粉丝,您可以这样做:

FB.api({
method: 'fql.query',
query: 'SELECT uid FROM page_fan WHERE uid=user_id AND page_id=page_id'
}, function(resp) {
if (resp.length) {
alert('A fan!')
} else {
alert('Not a fan!');
}
}
);

您可以在这里阅读更多相关信息:http://www.masteringapi.com/tutorials/facebook-api-check-if-a-user-is-fan-of-a-facebook-page/20/

类似问题:

Facebook Javascript, How to detect if user is a fan of my facebook page? While on my site?

关于javascript facebook 检查用户是否是页面的粉丝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15903006/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com