title: How to implement a twitter app to tweet through abraham/twitteroauth
body: <p>I am a very newbie to oAuth, PHP and Twitter programming. I am trying to develop one twitter app with Abraham Twitteroauth library. I have downloaded the source code from <a href="https://github.com/abraham/twitteroauth" rel="nofollow">https://github.com/abraham/twitteroauth</a> and I have put that in my WAMP's www location. 
  My config.php is</p>
  
  <pre><code>&lt;?php
  
  /**
   * @file
   * A single location to store configuration.
   */
  
  define('CONSUMER_KEY', 'nVD&lt;hidden&gt;');
  define('CONSUMER_SECRET', 'DKTAW17fwK&lt;hidden&gt;');
  define('OAUTH_CALLBACK', 'http://127.0.0.1/twitteroauth-master/twitteroauth-master/sdf.php');
  ?&gt;
  </code></pre>
  
  <p>I am pretty much sure about the Consumer key and secret as I get the login page. The sdf.php is the file where I used to make tweet</p>
  
  <pre><code>    &lt;?php
      /**
       * @file
       * 
       */
  
      /* Load required lib files. */
      session_start();
      require_once('twitteroauth/twitteroauth.php');
      require_once('config.php');
  
      /* If access tokens are not available redirect to connect page. */
      if (empty($_SESSION['access_token']) || empty($_SESSION['access_token']['oauth_token']) || empty($_SESSION['access_token']['oauth_token_secret'])) {
          header('Location: ./clearsessions.php');
      }
      /* Get user access tokens out of the session. */
      $access_token = $_SESSION['access_token'];
  
      /* Create a TwitterOauth object with consumer/user tokens. */
      $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);
  
      /* If method is set change API call made. Test is called by default. */
      $content = $connection-&gt;get('account/rate_limit_status');
      echo "Current API hits remaining: {$content-&gt;remaining_hits}.";
  
      /* Get logged in user to help with tests. */
      $user = $connection-&gt;get('account/verify_credentials');
  
      $active = FALSE;
      if (empty($active) || empty($_GET['confirmed']) || $_GET['confirmed'] !== 'TRUE') {
        echo '&lt;h1&gt;Warning! This page will make many requests to Twitter.&lt;/h1&gt;';
        echo '&lt;h3&gt;Performing these test might max out your rate limit.&lt;/h3&gt;';
        echo '&lt;h3&gt;Statuses/DMs will be created and deleted. Accounts will be un/followed.&lt;/h3&gt;';
        echo '&lt;h3&gt;Profile information/design will be changed.&lt;/h3&gt;';
        echo '&lt;h2&gt;USE A DEV ACCOUNT!&lt;/h2&gt;';
        echo '&lt;h4&gt;Before use you must set $active = TRUE in test.php&lt;/h4&gt;';
        echo '&lt;a href="./test.php?confirmed=TRUE"&gt;Continue&lt;/a&gt; or &lt;a href="./index.php"&gt;go back&lt;/a&gt;.';
        exit;
      }
  
      function twitteroauth_row($method, $response, $http_code, $parameters = '') {
        echo '&lt;tr&gt;';
        echo "&lt;td&gt;&lt;b&gt;{$method}&lt;/b&gt;&lt;/td&gt;";
        switch ($http_code) {
          case '200':
          case '304':
            $color = 'green';
            break;
          case '400':
          case '401':
          case '403':
          case '404':
          case '406':
            $color = 'red';
            break;
          case '500':
          case '502':
          case '503':
            $color = 'orange';
            break;
          default:
            $color = 'grey';
        }
        echo "&lt;td style='background: {$color};'&gt;{$http_code}&lt;/td&gt;";
        if (!is_string($response)) {
          $response = print_r($response, TRUE);
        }
        if (!is_string($parameters)) {
          $parameters = print_r($parameters, TRUE);
        }
        echo '&lt;td&gt;', strlen($response), '&lt;/td&gt;';
        echo '&lt;td&gt;', $parameters, '&lt;/td&gt;';
        echo '&lt;/tr&gt;&lt;tr&gt;';
        echo '&lt;td colspan="4"&gt;', substr($response, 0, 400), '...&lt;/td&gt;';
        echo '&lt;/tr&gt;';
  
      }
  
      function twitteroauth_header($header) {
        echo '&lt;tr&gt;&lt;th colspan="4" style="background: grey;"&gt;', $header, '&lt;/th&gt;&lt;/tr&gt;';
      }
  
      date_default_timezone_set('GMT');
  $parameters = array('status' =&gt; date(DATE_RFC822));
  $status = $connection-&gt;post('statuses/update', $parameters);
  twitteroauth_row('statuses/update', $status, $connection-&gt;http_code, $parameters);
  
      ?&gt;
  </code></pre>
  
  <p>I copy pasted this line from test.php.
  The problem I have is, when I go to the homepage, sign-in, it again redirect me to the connect.php. And it seems like its not saving any sessions. Please help me tp overcome this.</p>