开发者

Facebook: Determine if User is Fan (likes page)

Is there a way to deter开发者_运维技巧mine if the current user is a fan (now: likes the page) using facebook connect?

I know this is possible in the REST api, but I would like to be able to just use connect instead.


First you need to log the user in with Facebook connect and the Javascript SDK.

Then in Javascript you can use FB.api to call the Graph API.

FB.api('/me/likes');

This requires the user_likes permission to be granted when they login.

http://developers.facebook.com/docs/reference/api/user


I'd rather use FQL: SELECT page_id FROM page_fan WHERE uid=me() and page_id=114342017879

If the query returns an empty array, then your user is not fan. If it returns the page id in an array, then he's fan:

[
    {
        "page_id": "114342017879"
    }
]

Webservice url:

https://api.facebook.com/method/fql.query?query=SELECT+page_id+FROM+page_fan+WHERE+uid%3Dme%28%29+and+page_id%3D114342017879

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜