开发者

Facebook iframe page_fan in javascript

I am trying to make a check in a facebook application iframe tab to check if a user like a particular page or not, I am putting the following

FB.init({
    appId : '205563326143108',
    status : true, // check login status
    cookie : true, // enable cookies to allow the server to access the session
    xfbml : true // parse XFBML
});

function checkFan() {
    FB.api(
    { 
        method: 'fql.query', 
        query: 'SELECT uid FROM page_fan WHERE uid= ' + user_id + ' AND page_id=124571914229443' 
        },
    function(result) {
        if (result.length) { 
         document.getElementById('fan').style.display = 'block';
        } else {
         document.getElementById('non_fan').style.display = 'block';
        }
    });
}

FB.init seem to be working as I am using it for other things b开发者_如何学Pythonut checkFan function is not working.

Can someone help me please as I have been trying to make it work for a long period of time and I surrender finding solutions :(

Thanks


Use pages.isFan instead:

FB.api({
    method: 'pages.isFan',
    page_id: '124571914229443',
    uid: user_id
}, function (resp) {
    if (resp == true) {
        document.getElementById('fan').style.display = 'block';
    } else if (resp.error_code) {
        alert(resp.error_msg);
    } else {
        document.getElementById('non_fan').style.display = 'block';
    }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜