Hi,

First, at all, I want to wish happy new year for all members

I have a little problem. I have one php page with link for authorization on Twitter. When user click on that link, he gets popup window for allowing twitter application, and then popup automaticly close, send informations from URL (oauth_token etc) from PopUp window to parent window, and after that user get a little message. Here is the problem. When I send 'get' data from url to parent window, and auto-refresh parent window, it again calls JS function for getting parameters from URL and I get error "cannot read property 'location' of null"...My english is poor, so here my code and I hope that you help me

Code:
<?php
session_start();
require_once 'include/twitter.class.php';
echo "Welcome ".$_SESSION['login']."! <br />";
?>
<script type="text/javascript"> 
function twitter()
{

	window.open('./login.php?action=twitter','myWin','scrollbars =yes, width=500,height=500');
	window.onClick = function(){self.close()};
}
function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results != null )
	  return results[1];
  
    
}

function callTwitter()
{
	var a = gup('oauth_verifier');
	var b = gup('oauth_token');
	
		window.close();
		
		window.opener.location.search = '?oauth_token='+b+'&oauth_verifier='+a;
		
	
}
</script>
<a href="javascript:;" onClick="twitter();">Register Twitter</a>
<?php 
echo '


<form action="login.php" method="post">
<input type="submit" name="logout" value="Log Out"/>
</form>
';
if(isset($_POST['logout']))
{
	unset($_SESSION['login']);
	session_unset();
	header( "refresh:1;url=index.php" );
}
if(isset($_GET['action'])=="twitter")
{
	
	$t = new Twitter();
	$t->twitterLogin();
}


if(!empty($_GET['oauth_verifier']) && !empty($_SESSION['oauth_token']) && !empty($_SESSION['oauth_token_secret']))
{
		
	
		echo '<script type="text/javascript">callTwitter();
		</script>';
	
	
		echo 'Successful connecting with twitter';
}
	



?>
Twitter Class
Code:
	function twitterLogin()
	{
		// The TwitterOAuth instance
		$twitteroauth = new TwitterOAuth('uAVGfCIg9YqVhrmd5Rq1w', '9iqj4SBerAbcJ0uUnnbaAZn2o9OPFiTmIE9VVErJRy0');
		// Requesting authentication tokens, the parameter is the URL we will be redirected to
		$request_token = $twitteroauth->getRequestToken('http://localhost/sea/login.php');
		// Saving them into the session
		
		$_SESSION['oauth_token'] = $request_token['oauth_token'];
		$_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];
		// If everything goes well..
		if($twitteroauth->http_code==200)
		{
			// Let's generate the URL and redirect
			
			$url = $twitteroauth->getAuthorizeURL($request_token['oauth_token']);
			header('Location: '. $url);
		} else 
		{
			// It's a bad idea to kill the script, but we've got to know when there's an error.
			die('Something wrong happened.');
		}
	}