开发者

Authorization facebook (require login) with cakephp cause looping auth key session

im developing facebook iframe application with cakephp. My problem is i need facebook authorization soon as user visiting homepage. i'm put this code $user = $this->facebook->require_login(); in app_controller before filter method, seems its working with user authorization.

but after user authorize my applic开发者_如何学Goation is leaving facebook frame and go to normal page (not inside facebook), and i'm seeing this on address bar "auth_token=f754dc2ed39b5e2b93f11a6e648f1517&installed=1".

then when im click link to another page on my application seems that auth_token key is looping on address bar.

how can i fix this? thanks


You can do something like:

public function beforeFilter() {

        $this->fbsession = $this->facebook->getSession ();      
        $this->me = null;

        // Session based API call.
        if ($this->fbsession) {
            try {
                $this->uid = $this->facebook->getUser ();
                $this->me = $this->facebook->api ( '/me' );
            } catch ( FacebookApiException $e ) {
                error_log ( $e );
            }
        } else {
            $this->layout = 'login';
            $this->viewPath = 'pages';
            $this->render('login');
        }
}

If the user is not loggedin to Facebook and/or your app has no access, he's redirect to the /views/pages/login.ctp view. That's where you put your code for login in (like in the sdk example).


You can redirect the callback to a specific page that is set up to handle the facebook authorisation callbacks and use that to log the user in and then redirect them to the appropriate location on the site (e.g. memebers page)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜