我正在制作一个网站,可以在FB上发布一个简单的锦标赛注册页面。但FB FB应用程序并未向所有人提供授权。
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId : 'XXXX',
status : true,
cookie : true,
xfbml : true
});
</script>
<script>
// Additional initialization code here
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
</script>
<script type="text/javascript">
$(document).ready(function(){
FB.getLoginStatus(function(response) {
if (response.status == 'connected') {
var user_id = response.authResponse.userID;
var page_id = "XXXXX"; //coca cola
var fql_query = "SELECT uid FROM page_fan WHERE page_id =" + page_id + " AND uid=" + user_id;
var the_query = FB.Data.query(fql_query);
the_query.wait(function(rows) {
if (rows.length == 1 && rows[0].uid == user_id) {
$("#container_like").show();
alert("you like us");
//here you could also do some ajax and get the content for a "liker" instead of simply showing a hidden div in the page.
} else {
$("#container_notlike").show();
alert("you don't like us");
//and here you could get the content for a non liker in ajax...
}
});
} else {
// user is not logged in
}
});
});
这是我的代码。应检查实际用户是否连接到FB,如果是,检查他是否喜欢该页面.Ana显示其中一个div。当我是用户时(我是管理员FB应用程序)一切都还可以,但如果它是其他人则不行。它显示没有使用APP的身份验证。 感谢所有人:)