QuickBooks/IPP/IntuitAnywhere.php
public function handle($app_username, $app_tenant)
	{
		if ($this->check($app_username, $app_tenant) and 		// We have tokens ...
			$this->test($app_username, $app_tenant))			// ... and they are valid
		{
			// They are already logged in, send them on to exchange data
			header('Location: ' . $this->_that_url);
			exit;
		}
		else
		{
			if (isset($_GET['oauth_token']))
			{
				// We're in the middle of an OAuth token session
				
				/*
				$arr = mysql_fetch_array(mysql_query("
					SELECT
						*
					FROM
						quickbooks_oauth
					WHERE
						oauth_request_token = '" . $_REQUEST['oauth_token'] . "' "));
				*/
				
				if ($arr = $this->_driver->oauthRequestResolve($_GET['oauth_token']))
				{
					$info = $this->_getAccessToken(
						$arr['oauth_request_token'], 
						$arr['oauth_request_token_secret'], 
						$_GET['oauth_verifier']);
					
					//print('got back [' . $info . ']');
					//print_r($info);
					//exit;
					
					if ($info)
					{
						/*
						mysql_query("
							UPDATE
								quickbooks_oauth
							SET
								oauth_access_token = '" . $info['oauth_token'] . "', 
								oauth_access_token_secret = '" . $info['oauth_token_secret'] . "', 
								qb_realm = '" . $_REQUEST['realmId'] . "', 
								qb_flavor = '" . $_REQUEST['dataSource'] . "'
							WHERE
								quickbooks_oauth_id = " . $arr['quickbooks_oauth_id']);
						*/
						
						$this->_driver->oauthAccessWrite(
							$this->_key, 
							$arr['oauth_request_token'], 
							$info['oauth_token'], 
							$info['oauth_token_secret'],
							$_GET['realmId'], 
							$_GET['dataSource']);
						
						//print_r($_REQUEST);
						//exit;
						//print_r($info);
		
						//print('authd now, go here <a href="exchange_data.php">exchange_data.php</a>');
						header('Location: ' . $this->_that_url);
						exit;
					}
					else
					{
						// Something went wrong when fetching the user token...?
						print('something went wrong fetching user token');
					}
				}
				else
				{
					print('something went wrong... invalid oauth token?');
				}
			}
			else
			{
				$auth_url = $this->_getAuthenticateURL($app_username, $app_tenant, $this->_this_url);
				
				// Forward them to the auth page
				header('Location: ' . $auth_url);
				exit;
			}
		}
		
		return true;
	}
public function handle($app_username, $app_tenant)
	{
		if ($this->check($app_username, $app_tenant) and 		// We have tokens ...
			$this->test($app_username, $app_tenant))			// ... and they are valid
		{
			// They are already logged in, send them on to exchange data
			header('Location: ' . $this->_that_url);
			exit;
		}
		else
		{
			if (isset($_GET['oauth_token']))
			{
				// We're in the middle of an OAuth token session
				
				/*
				$arr = mysql_fetch_array(mysql_query("
					SELECT
						*
					FROM
						quickbooks_oauth
					WHERE
						oauth_request_token = '" . $_REQUEST['oauth_token'] . "' "));
				*/
				
				if ($arr = $this->_driver->oauthRequestResolve($_GET['oauth_token']))
				{
					$info = $this->_getAccessToken(
						$arr['oauth_request_token'], 
						$arr['oauth_request_token_secret'], 
						$_GET['oauth_verifier']);
					
					//print('got back [' . $info . ']');
					//print_r($info);
					//exit;
					
					if ($info)
					{
						/*
						mysql_query("
							UPDATE
								quickbooks_oauth
							SET
								oauth_access_token = '" . $info['oauth_token'] . "', 
								oauth_access_token_secret = '" . $info['oauth_token_secret'] . "', 
								qb_realm = '" . $_REQUEST['realmId'] . "', 
								qb_flavor = '" . $_REQUEST['dataSource'] . "'
							WHERE
								quickbooks_oauth_id = " . $arr['quickbooks_oauth_id']);
						*/
						
						$this->_driver->oauthAccessWrite(
							$this->_key, 
							$arr['oauth_request_token'], 
							$info['oauth_token'], 
							$info['oauth_token_secret'],
							$_GET['realmId'], 
							$_GET['dataSource']);
						
						//print_r($_REQUEST);
						//exit;
						//print_r($info);
		
						//print('authd now, go here <a href="exchange_data.php">exchange_data.php</a>');
						header('Location: ' . $this->_that_url);
						exit;
					}
					else
					{
						// Something went wrong when fetching the user token...?
						print('something went wrong fetching user token');
					}
				}
				else
				{
					print('something went wrong... invalid oauth token?');
				}
			}
			else
			{
				$auth_url = $this->_getAuthenticateURL($app_username, $app_tenant, $this->_this_url);
				
				// Forward them to the auth page
				header('Location: ' . $auth_url);
				exit;
			}
		}
		
		return true;
	}
Handle an OAuth request login thing