I am creating a Facebook fan-gate that when a user likes my page it will show a form that will allow a user to enter a competition.
How would i go about checking if the user has already entered the competition.
So when the browsers requests the iframe containing my Facebook page, my php file will first check if the user has already entered the competition(based on the user facebook id), if they have then show a certain image, if not show the input form for the competition.
edit
so this is my code at the moment
<?php
require_once 'facebook-php-sdk/src/facebook.php';
$fbAppArray = array(
'appId' => 'xxx',
'secert' => 'xxxxxxx',
);
$fbAppObj = new Facebook( $fbAppArray );
$signedRequest = $fbAppObj->getSignedRequest();
function parsePageSignedRequest()
{
if( isset( $_REQUEST['signed_request'] ) )
{
$encoded_sig = null;
$payload = null;
list( $encoded_sig, $payload ) = explode( '.', $_REQUEST['signed_request'], 2 );
$sig = base64_decode( strtr( $encoded_sig, '-_', '+/' ) );
$data = json_decode( base64_decode( strtr( $payload, '-_', '+/' ), true ) );
return $data;
}
return false;
}
?>
i then call this
<?php
if( $signedRequest == parsePageSignedRequest() )
{
if( $signedRequest->page->liked )
{
echo "you liked me";
}else{
echo "Please like the application so you will be able to see the contents...";
}
}
?>
this is too check if the user has liked the page or not, but it does not seem to work.
( $signedRequest->page->liked ) this seems to always evaluate to false even if the user liked the page
any ideas why?
Cheers
i hope you are storing the results of form submission in a table, you can store a
userIDcolumn there containing the facebook’s userID, and then can match against it, you will “have” to get users basic information. the other option is to have user type there email, but it is not guranteed.