我试图检查用户是否安装了我的应用程序。 流程如下 :
1. Check whether has installed or authorize my app
2. If yes, then direct user to play my app directly
If no, then direct user to see welcoming page to read term of use and privacy.
我似乎没有访问符号来检查权限。 它显示在下面错误 。
Fatal error: Uncaught OAuthException: An active access token must be used to query information about the current user
我的代码是这样的。 我还会回声 $access_token 来查看我是否收到了存取凭证 。 是的, 我确实得到了代码, 但不知怎么我还是得到了错误 。
require_once( src/facebook.php );
$app_id = "APP_ID";
$app_secret = "APP_secret";
// Init facebook api.
$facebook = new Facebook(array(
appId => $app_id,
secret => $app_secret,
cookie => false,
));
$access_token = $facebook->getAccessToken();
//echo $access_token;
$permissions = $facebook->api("/me/permissions", $access_token);
if( array_key_exists( publish_stream , $permissions[ data ][0]) ) {
// Permission is granted!
echo "App has been installed";
//then redirect to content page
} else {
echo "App has not been installed";
//then redirect user to welcoming page and let user read "term of use" and "privasy"
}
请救救我