title: Twitter Authentication In Fancybox Or lightbox
body: <p>This is a question i think is worthwhile to know and useful for others, because i think a lot of people love those fancybox and lightbox pop ups rather than the normal window pop ups you usually get.</p>
  
  <p>I am asking a question if this is possible to put the twitter authentication inside a fancybox/lightbox, so once a user clicks the <strong>Sign In With Twitter</strong> button, it then opens that inside a nice fancybox or even a lightbox?</p>
  
  <p>I did some searches via google and stackoverflow, i can't find anything relevant that helps answer this question?</p>
  
  <p>So currently i now have this page <a href="https://www.tubenations.com/twitter.php" rel="nofollow">https://www.tubenations.com/twitter.php</a> (note this link won't work unless you have an account and are logged in!)</p>
  
  <p>I already have fancybox installed on my site for other elements, but i just think it would look nicer if this was possible to put the twitter auth screen inside fancybox?</p>
  
  <p>so the current setup is as follows on my twitter.php page</p>
  
  <pre><code>&lt;hr&gt;
  &lt;div class="twitterInfo2"&gt;In order for you to view and appear on this page you need to authenticate your twitter account by clicking sign in with twitter button below!
    &lt;br /&gt;
  &lt;/div&gt;
  &lt;br /&gt;
  &lt;a href="/twitter/process.php"&gt;
    &lt;img class="twitterImage" src="/twitter/images/sign-in-with-twitter.png" title="Tube Nations Link Your Twitter" alt="Tube Nations Link Your Twitter" /&gt;
  &lt;/a&gt;
  &lt;hr&gt;
  </code></pre>
  
  <p>so basically it is the <strong>/twitter/process.php</strong> file that does the work, I will post the code for the process.php file too, because I also think that file needs to be adjusted with the fancybox inclusion code if it is at all possible?? </p>
  
  <pre><code>if(isset($_REQUEST['oauth_token']) &amp;&amp; $_SESSION['token']  !== $_REQUEST['oauth_token']) {
  
  //If token is old, distroy session and redirect user to index.php
  session_destroy();
  header('Location: index.php');
  
  }elseif(isset($_REQUEST['oauth_token']) &amp;&amp; $_SESSION['token'] == $_REQUEST['oauth_token']) {
  
  //Successful response returns oauth_token, oauth_token_secret, user_id, and screen_name
  $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['token'] , $_SESSION['token_secret']);
  $access_token = $connection-&gt;getAccessToken($_REQUEST['oauth_verifier']);
  
  include_once("../inc/header_session.php");
  
      if($connection-&gt;http_code == '200' &amp;&amp; $tn_userid != 1)
  {
      //Redirect user to twitter
      $_SESSION['status'] = 'verified';
      $_SESSION['request_vars'] = $access_token;
  
  //Insert user into the database
      $user_info = $connection-&gt;get('account/verify_credentials'); 
      $name = explode(" ",$user_info-&gt;name);
      $fname = isset($name[0])?$name[0]:'';
      $lname = isset($name[1])?$name[1]:'';
      $db_user = new Users();
      $db_user-&gt;checkUsers('twitter',$user_info-&gt;id,$user_info-&gt;screen_name,$fname,$lname,$user_info-&gt;lang,$access_token['oauth_token'],$access_token['oauth_token_secret'],$user_info-&gt;profile_image_url,$user-&gt;data['user_id']);
  
          //Unset no longer needed request tokens
      unset($_SESSION['token']);
      unset($_SESSION['token_secret']);
      header('Location: /twitter.php');
  }else{
      die("error, try again later!");
  }         }
  
  
  }else{
  
  if(isset($_GET["denied"]))
  {
      header('Location: /twitter.php');
      die();
  }
  
      //Fresh authentication
  $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
  $request_token = $connection-&gt;getRequestToken(OAUTH_CALLBACK);
  
  //Received token info from twitter
  $_SESSION['token']          = $request_token['oauth_token'];
  $_SESSION['token_secret']   = $request_token['oauth_token_secret'];
  
  
      //Any value other than 200 is failure, so continue only if http code is 200
  if($connection-&gt;http_code == '200')
  {
      //redirect user to twitter
      $twitter_url = $connection-&gt;getAuthorizeURL($request_token['oauth_token']);
      header('Location: ' . $twitter_url); 
  }else{
      die("error connecting to twitter! try again later!");
  }}
  </code></pre>
  
  <p>I hope it is possible?</p>