Facebook signed_request returns NULL
I have create new iframe app on facebook and want to detect whether the user is a fan or not of the current page so I use the $_REQUEST['signed_request'] variable as described here: http://developers.facebook.com/docs/authentication/signed_request/. However $_REQUEST['signed_request'] variable always returns NULL, not what it should actually return. Has anyone ever encountered the 开发者_StackOverflow社区same problem? I'm quite familiar with creating apps on facebook but can't figure out what could be the reason of this problem... Any ideas?
Make sure that in your Page tab url you specify the name of the page for example http://yourdomain.com/myapp/index.php instead of just http://yourdomain.com/myapp
The signed request only seems to get posted if you specify the exact page
You can use Facebook Query Language (FQL) to check if the current user is a Fan of your page.
function userIsFan()
{
global $page_id, $facebook, $access_token;
$fql = "SELECT uid from page_fan WHERE uid=me() AND page_id='".$page_id."'";
$param = array('method' => 'fql.query',
'access_token' => $access_token,
'query' => $fql,
'callback' => '');
$response = $facebook->api($param);
if (isset($response[0]))
{
return true;
}
return false;
}
Things to take note of...
me() is a method that automatically gets the user id of the current user.
$page_id should be containing your Facebook Page id that you have specified in fbmain.php
精彩评论