Javascript 如何获取facebook pageid以访问喜欢的内容?
请帮助我一步一步地完成我的任务。 我认为我的任务是典型的 我想了解当前用户是否喜欢我的应用程序 我在谷歌上搜索了几天,但没有最终结果 请指出我的错误 我的消息来源对一些垃圾感到抱歉:Javascript 如何获取facebook pageid以访问喜欢的内容?,javascript,jquery,facebook,facebook-like,facebook-javascript-sdk,Javascript,Jquery,Facebook,Facebook Like,Facebook Javascript Sdk,请帮助我一步一步地完成我的任务。 我认为我的任务是典型的 我想了解当前用户是否喜欢我的应用程序 我在谷歌上搜索了几天,但没有最终结果 请指出我的错误 我的消息来源对一些垃圾感到抱歉: <!DOCTYPE html> <html> <head> <script src="js/jquery.js" type="text/javascript"></script> <script src="http://connec
<!DOCTYPE html>
<html>
<head>
<script src="js/jquery.js" type="text/javascript"></script>
<script src="http://connect.facebook.net/en_US/all.js"></script>
</head>
<body>
<div id="status"></div>
<div id="features"></div>
<div id="fb-root"></div>
<script>
function showFeatures() {
$("#features")[0].innerHTML = hasFunctions ? 'feauture are available' : 'features are NOT available';
}
function statusChangeCallback(response) {
console.log(response);
if (response.status === 'connected') {
FB.api('/me', function(response) {
console.log(response);
});
FB.api('/me/likes/PAGEID', function(response) {
console.log(response.data);
});
// Logged into your app and Facebook.
$("#buttonLogin").hide();
$("#buttonLike").show();
} else if (response.status === 'not_authorized') {
// The person is logged into Facebook, but not your app.
$("#status")[0].innerHTML = 'Please log into this app.';
$("#buttonLogin").show();
$("#buttonLike").hide();
} else {
// The person is not logged into Facebook, so we're not sure if
// they are logged into this app or not.
$("#status")[0].innerHTML = 'Please log into Facebook';
$("#buttonLogin").show();
$("#buttonLike").hide();
}
showFeatures();
}
function checkLoginState() {
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
}
window.fbAsyncInit = function() {
FB.init({
appId: MYAPPID,
status:true,
cookie : true
});
FB.Event.subscribe('edge.create', function(response) {
alert('You liked the URL: ' + response);
});
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
}
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id; //js.async = true;
js.src = "//connect.facebook.net/de_DE/all.js#xfbml=1&appId=APPID";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<div id="buttonLike" class="fb-like" data-href="http://share-box.com" data-layout="button" data-action="like" data-show-faces="false" data-share="false"></div>
<fb:login-button id="buttonLogin" scope="public_profile,email" onlogin="checkLoginState();"> </fb:login-button>
</body>
</html>
结果我
-登录按钮,我可以登录-好
喜欢按钮,我可以喜欢/不喜欢-好
我可以使用获取用户信息
FB.api'/me',functionresponse
但是当我想和你一样的时候
FB.api'/me/likes/PAGEID',functionresponse
我总是将空JSON数组[]作为响应
PageID作为来自的响应的“id”字段获取
我的错误在哪里?我应该如何行动才能获得类似的状态?您将无法做到这一点。用户需要授予用户喜欢,但对于您的用例,您不能使用用户喜欢,因此不会possible@WizKid谢谢你的回答。请澄清我为什么不能使用user_like?只有在增强用户体验的情况下才允许使用user_like。像选通或只是显示或不显示按钮都不符合条件。@WizKid有办法解决我的任务吗?没有。这是违反Facebook平台政策的