I know there are several free applications inside facebook that gives you the facility of if a use开发者_如何学Pythonr is FAN go to a xyz.php program or shows a image. If the user clicks "like" then go to a vwx.php program or shows a image. I have been trying to do the same as those free applications using FB.Event.subscribe inside a php facebook application but i'm tired of trying. I know it should be as simple as:
if user is fan {location.href='xyz.php'} else{location.href='vwx.php'}
BUT HOW DO I KNOW THE USER IS FAN OR NOT
please help !!! Thanks
You should familiarise yourself with the *signed_request* parameter:
http://developers.facebook.com/docs/authentication/signed_request/
If you scroll down the page, you'll find a PHP function that shows you how to verify and decode *signed_request*.
Add the function to your code and call it like this:
$data = parse_signed_request($_REQUEST['signed_request'],'YOUR_APP_SECRET');
Now you can access the objects in the signed_request as PHP arrays:
if($data['page']['liked']) { //show content for fans }
else { //show content for others }
精彩评论