简体   繁体   中英

Facebook, check if user is a fan and logged in using PHP

I have searched the Internet and SO for over a week, but have not managed to find anything yet so allow me to ask a question which has already been asked loads of time on SO, but for which none of the answers seem to be working for me.

I have a website and a Facebook page. On my website I have the usual Facebook "Like me" box. As I want to show some extra content to my fans when they visit the website - and encourage non-fans to become a fan - I would like to know if it is possible, via PHP, to:
1. Understand if the user is a fan
2. Understand if the user is logged into Facebook

What I would like to be able to do is send a PHP request to Facebook and receive one of the following three answers: "is a fan", "not a fan", "not logged-in/not a Facebook user".

In the first case I would show the fan-only content, in the secon case I would try to encourage the user to become a fan, while in the third case I would not do anything as I'm not sure the user is a Facebook user.

Please note:
1. I do not need any further identifying information
2. There is no app involved here, as users are fans of my page, although I could build one if necessary

Some answers on SO seem to point to this tutorial, but as my page is not an app, I cannot really use this solution:
http://www.masteringapi.com/tutorials/facebook-api-check-if-a-user-is-fan-of-a-facebook-page/20/

Unfortunately Facebook's APIs won't tell you if the user's logged in or if is a fan of your page until you make the user install your Facebook app (and for the likes you will need user_likes permission too).

The only kind of exception is that when you are running a page tab. At the time facebook embeds your content via an <iframe> , the signed_request POST parameter that comes with it will tell you if the user is a fan or not. You can read about the signed request's here. .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM