<div class="like-button">
<div class="fb-like-box" data-href="https://www.facebook.com/pages/Annupurnas-Cooking/526672940684211?ref=hl" data-width="292" data-show-faces="true" data-stream="true" data-header="true"></div>
<div id="fb-root"></div>
<script type="text/javascript">
<!--
var fbAsyncInit = function() {
var APP_ID = '324859924285629';
var PAGE_ID = '526672940684211';
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
});
FB.Event.subscribe('auth.sessionChange', function(response) {
if(response.session){
//check to see if user is a fan of the page
var query = FB.Data.query( 'select page_id from page_fan where uid='+response.session.uid+' and page_id ='+PAGE_ID);
query.wait( function(rows) {
if(rows.length){
//user already likes your page
}else{
//user has not yet liked your page
}
});
}else{
//user has not yet logged in
}
});
FB.Event.subscribe('edge.create', function(response) {
//user just clicked "like" on your page
});
FB.Event.subscribe('edge.remove', function(response) {
//user just clicked "unlike" on your page
});
};
(function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
//-->
</script>
</div>
我想实现我的facebook页面的like按钮。我想检查当前用户是否喜欢我们。有人可以告诉我我们如何做到这一点。
在代码中,我输入了我的 appId 和 facebook 页面 ID。我尝试使用它,但它错误地告诉我“必须使用活动访问令牌来查询有关当前用户的信息。”。
有人知道我如何将访问令牌放入此。我是否需要将 accesstoken 用于类似的功能。