I'm trying to implement the facebook login flow in my site using mostly php.

When user is already logged in with a valid session, i succeeded to post a message on his wall.
When the user is not logged in i open the login window and the troubles begin...

If the user succeeded to login he is redirected to my connect.php, because that why i configured in my facebook settings - BUT in the new login window instead of my main window.

My Question:
How do i close the login window and redirect to connect.php in the main window.

$facebook = $GLOBALS['_fb'];
    if (!$facebook ) {
        drupal_set_message('no facebook ');
        return;
    }
    
	$session = $facebook->getSession();

	$me = null;
	// Session based API call.
	if ($session) {
		try {
			drupal_set_message('Got Session');
			$uid = $facebook->getUser();
			$me = $facebook->api('/me');
		} catch (FacebookApiException $e) {
			error_log($e);
		}
	}
	else {
		drupal_set_message('No Session');

		// User has not authorized us or is not logged in
		$params = array (
        	'fbconnect'=>0,
        	'req_perms'=>'publish_stream,email',
        	'canvas'=>0  ,
            'display'=>'popup',
		    'next' => 'connect.php',
		//'cancel_url' => $currentUrl,
		);
		$loginUrl = $facebook->getLoginUrl($params);
		if ($loginUrl) {
			?>
            <script type="text/javascript">
                var newwindow;
                width    = 500,
                height   = 270,
                left     = parseInt(screenX + ((outerWidth - width) / 2), 10),
                top      = parseInt(screenY + ((outerHeight - height) / 2.5), 10),
                features = (
                  'width=' + width +
                  ',height=' + height +
                  ',left=' + left +
                  ',top=' + top
                );
         
                newwindow=window.open('<?=$loginUrl?>','Login by facebook',features);
            </script>
			<?php
		}
	}

Comments

chenop’s picture

Status: Active » Closed (fixed)

Figure it out,

In the next url - in my case its connect.php, in the end of the file i invoke the javascript command close().

window.close();