问题
Following is the code that use to check weather user has granted me permissions.If the User denies the permission, my app redirects the user again to facebook for permissions.
<?php
if(isset($_REQUEST['error'])){//ok some error has occurred from Facebook
if(isset($_REQUEST['error_reason']) && $_REQUEST['error_reason']=='user_denied'){// ok so the error has occurred coz the user denied permissions!
require 'lib/facebook.php';
$facebook_appid='XXXXX';
$facebook_app_secret='XXXXX';
$facebook = new Facebook(array(
'appId' => $facebook_appid,
'secret' => $facebook_app_secret,
));
$loginUrl = $facebook->getLoginUrl(
array(
'scope' => 'email,read_mailbox,publish_stream,user_birthday,user_location,read_stream,user_work_history,user_about_me,user_hometown'
)
);
echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>";
}
}
$pt['start']=microtime(true);
include_once "fblogin.php";
require 'lib/fbconfig.php';
$userdata=$facebook->api('/me');
$at= $facebook->getAccessToken();
// Now rest of code fetches users data and post message on wall
Now if the user rejects the permissions, the above code is executed and the user is redirected again to the facebook.Now if this time the user chooses to accept, There is endless redirection between facebook and my canvas url. (By the way, my app is iframe based app on facebook). How do I fix it? Additionally how do I check if the user has granted me all extended permissions?
来源:https://stackoverflow.com/questions/11343578/redirection-between-facebook-and-my-app-canvas-never-stops