Redirection between facebook and my app canvas never stops

醉酒当歌 提交于 2019-12-12 05:39:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!