title: Getting Bad Authentication Data error from Twitter API
body: <p>Ok, so I have been using the Abraham William Twitter API library on Github to try pulling my followers on Twitter on my website , but I am getting a bad authentication error "Bad Authentication data [code] => 215" even though I followed the steps . Below is the code that authenticates me and supposed to help me try the different methods to request data from Twitter .. Could someone please tell me why I am getting this error , I would greatly appreciate it .. Abraham's twitter library documentation can be found here ..
  <a href="https://github.com/abraham/twitteroauth" rel="nofollow">https://github.com/abraham/twitteroauth</a></p>
  
  <pre><code> &lt;?php
      /**
       * @file
       * 
       */
  
      /* Load required lib files. */
      //session_start();
      require_once('../madscore/twitter/twitteroauth/twitteroauth.php');
      require_once('../madscore/twitter/config.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');
      var_dump($user);
  
  
  
  
  
  
      $active = TRUE;
      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="../index3.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;';
      }
  
      /* Start table. */
      echo '&lt;br&gt;&lt;br&gt;';
      echo '&lt;table border="1" cellpadding="2" cellspacing="0"&gt;';
      echo '&lt;tr&gt;';
      echo '&lt;th&gt;API Method&lt;/th&gt;';
      echo '&lt;th&gt;HTTP Code&lt;/th&gt;';
      echo '&lt;th&gt;Response Length&lt;/th&gt;';
      echo '&lt;th&gt;Parameters&lt;/th&gt;';
      echo '&lt;/tr&gt;&lt;tr&gt;';
      echo '&lt;th colspan="4"&gt;Response Snippet&lt;/th&gt;';
      echo '&lt;/tr&gt;';
  
      /**
       * Help Methods.
       */
      twitteroauth_header('Help Methods');
  
      /* help/test */
      twitteroauth_row('help/test', $connection-&gt;get('help/test'), $connection-&gt;http_code);
  
  
      /**
       * Timeline Methods.
       */
      twitteroauth_header('Timeline Methods');
  
      /* statuses/public_timeline */
      twitteroauth_row('statuses/public_timeline', $connection-&gt;get('statuses/public_timeline'), $connection-&gt;http_code);
  
      /* statuses/public_timeline */
      twitteroauth_row('statuses/home_timeline', $connection-&gt;get('statuses/home_timeline'), $connection-&gt;http_code);
  
      /* statuses/friends_timeline */
      twitteroauth_row('statuses/friends_timeline', $connection-&gt;get('statuses/friends_timeline'), $connection-&gt;http_code);
  
      /* statuses/user_timeline */
      twitteroauth_row('statuses/user_timeline', $connection-&gt;get('statuses/user_timeline'), $connection-&gt;http_code);
  
      /* statuses/mentions */
      twitteroauth_row('statuses/mentions', $connection-&gt;get('statuses/mentions'), $connection-&gt;http_code);
  
      /* statuses/retweeted_by_me */
      twitteroauth_row('statuses/retweeted_by_me', $connection-&gt;get('statuses/retweeted_by_me'), $connection-&gt;http_code);
  
      /* statuses/retweeted_to_me */
      twitteroauth_row('statuses/retweeted_to_me', $connection-&gt;get('statuses/retweeted_to_me'), $connection-&gt;http_code);
  
      /* statuses/retweets_of_me */
      twitteroauth_row('statuses/retweets_of_me', $connection-&gt;get('statuses/retweets_of_me'), $connection-&gt;http_code);
  
  
      /**
       * Status Methods.
       */
      twitteroauth_header('Status Methods');
  
      /* statuses/update */
      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);
  
      /* statuses/show */
      $method = "statuses/show/{$status-&gt;id}";
      twitteroauth_row($method, $connection-&gt;get($method), $connection-&gt;http_code);
  
      /* statuses/destroy */
      $method = "statuses/destroy/{$status-&gt;id}";
      twitteroauth_row($method, $connection-&gt;delete($method), $connection-&gt;http_code);
  
      /* statuses/retweet */
      $method = 'statuses/retweet/6242973112';
      twitteroauth_row($method, $connection-&gt;post($method), $connection-&gt;http_code);
  
      /* statuses/retweets */
      $method = 'statuses/retweets/6242973112';
      twitteroauth_row($method, $connection-&gt;get($method), $connection-&gt;http_code);
  
  
      /**
       * User Methods.
       */
      twitteroauth_header('User Methods');
  
      /* users/show */
      $method = 'users/show/27831060';
      twitteroauth_row($method, $connection-&gt;get($method), $connection-&gt;http_code);
  
      /* users/search */
      $parameters = array('q' =&gt; 'oauth');
      twitteroauth_row('users/search', $connection-&gt;get('users/search', $parameters), $connection-&gt;http_code, $parameters);
  
      /* statuses/friends */
      $method = 'statuses/friends/27831060';
      twitteroauth_row($method, $connection-&gt;get($method), $connection-&gt;http_code);
  
      /* statuses/followers */
      $method = 'statuses/followers/27831060';
      twitteroauth_row($method, $connection-&gt;get($method), $connection-&gt;http_code);
  
  
      /**
       * List Methods.
       */
      twitteroauth_header('List Methods');
  
      /* POST lists */
      $method = "{$user-&gt;screen_name}/lists";
      $parameters = array('name' =&gt; 'Twitter OAuth');
      $list = $connection-&gt;post($method, $parameters);
      twitteroauth_row($method, $list, $connection-&gt;http_code, $parameters);
  
      /* POST lists id */
      $method = "{$user-&gt;screen_name}/lists/{$list-&gt;id}";
      $parameters = array('name' =&gt; 'Twitter OAuth List 2');
      $list = $connection-&gt;post($method, $parameters);
      twitteroauth_row($method, $list, $connection-&gt;http_code, $parameters);
  
      /* GET lists */
      $method = "{$user-&gt;screen_name}/lists";
      twitteroauth_row($method, $connection-&gt;get($method), $connection-&gt;http_code);
  
      /* GET lists id */
      $method = "{$user-&gt;screen_name}/lists/{$list-&gt;id}";
      twitteroauth_row($method, $connection-&gt;get($method), $connection-&gt;http_code);
  
      /* DELETE list */
      $method = "{$user-&gt;screen_name}/lists/{$list-&gt;id}";
      twitteroauth_row($method, $connection-&gt;delete($method), $connection-&gt;http_code);
  
      /* GET list statuses */
      $method = "oauthlib/lists/4097351/statuses";
      twitteroauth_row($method, $connection-&gt;get($method), $connection-&gt;http_code);
  
      /* GET list members */
      $method = "{$user-&gt;screen_name}/lists/memberships";
      twitteroauth_row($method, $connection-&gt;get($method), $connection-&gt;http_code);
  
  
      /* GET list subscriptions */
      $method = "{$user-&gt;screen_name}/lists/subscriptions";
      twitteroauth_row($method, $connection-&gt;get($method), $connection-&gt;http_code);
  
  
      /**
       * List Members Methods.
       */
      twitteroauth_header('List Members Methods');
  
      /* Create temp list for list member methods. */
      $method = "{$user-&gt;screen_name}/lists";
      $parameters = array('name' =&gt; 'Twitter OAuth Temp');
      $list = $connection-&gt;post($method, $parameters);
  
  
      /* POST list members */
      $parameters = array('id' =&gt; 27831060);
      $method = "{$user-&gt;screen_name}/{$list-&gt;id}/members";
      twitteroauth_row($method, $connection-&gt;post($method, $parameters), $connection-&gt;http_code, $parameters);
  
      /* GET list members */
      $method = "{$user-&gt;screen_name}/{$list-&gt;id}/members";
      twitteroauth_row($method, $connection-&gt;get($method), $connection-&gt;http_code);
  
      /* GET list members id */
      $method = "{$user-&gt;screen_name}/{$list-&gt;id}/members/27831060";
      twitteroauth_row($method, $connection-&gt;get($method), $connection-&gt;http_code);
  
      /* DELETE list members */
      $parameters = array('id' =&gt; 27831060);
      $method = "{$user-&gt;screen_name}/{$list-&gt;id}/members";
      twitteroauth_row($method, $connection-&gt;delete($method, $parameters), $connection-&gt;http_code, $parameters);
  
      /* Delete the temp list */
      $method = "{$user-&gt;screen_name}/lists/{$list-&gt;id}";
      $connection-&gt;delete($method);
  
  
      /**
       * List Subscribers Methods.
       */
      twitteroauth_header('List Subscribers Methods');
  
  
      /* POST list subscribers */
      $method = 'oauthlib/test-list/subscribers';
      twitteroauth_row($method, $connection-&gt;post($method), $connection-&gt;http_code);
  
      /* GET list subscribers */
      $method = 'oauthlib/test-list/subscribers';
      twitteroauth_row($method, $connection-&gt;get($method), $connection-&gt;http_code);
  
      /* GET list subscribers id */
      $method = "oauthlib/test-list/subscribers/{$user-&gt;id}";
      twitteroauth_row($method, $connection-&gt;get($method), $connection-&gt;http_code);
  
      /* DELETE list subscribers */
      $method = 'oauthlib/test-list/subscribers';
      twitteroauth_row($method, $connection-&gt;delete($method), $connection-&gt;http_code);
  
  
      /**
       * Direct Message Methods.
       */
      twitteroauth_header('Direct Message Methods');
  
      /* direct_messages/new */
      $parameters = array('user_id' =&gt; $user-&gt;id, 'text' =&gt; 'Testing out @oauthlib code');
      $method = 'direct_messages/new';
      $dm = $connection-&gt;post($method, $parameters);
      twitteroauth_row($method, $dm, $connection-&gt;http_code, $parameters);
  
      /* direct_messages */
      $method = 'direct_messages';
      twitteroauth_row($method, $connection-&gt;get($method), $connection-&gt;http_code);
  
      /* direct_messages/sent */
      $method = 'direct_messages/sent';
      twitteroauth_row($method, $connection-&gt;get($method), $connection-&gt;http_code);
  
      /* direct_messages/sent */
      $method = "direct_messages/destroy/{$dm-&gt;id}";
      twitteroauth_row($method, $connection-&gt;delete($method), $connection-&gt;http_code);
  
  
      /**
       * Friendships Methods.
       */ 
      twitteroauth_header('Friendships Methods');
  
      /* friendships/create */
      $method = 'friendships/create/93915746';
      twitteroauth_row($method, $connection-&gt;post($method), $connection-&gt;http_code);
  
      /* friendships/show */
      $parameters = array('target_id' =&gt; 27831060);
      $method = 'friendships/show';
      twitteroauth_row($method, $connection-&gt;get($method, $parameters), $connection-&gt;http_code, $parameters);
  
      /* friendships/destroy */
      $method = 'friendships/destroy/93915746';
      twitteroauth_row($method, $connection-&gt;post($method), $connection-&gt;http_code);
  
  
      /**
       * Social Graph Methods.
       */
      twitteroauth_header('Social Graph Methods');
  
      /* friends/ids */
      $method = 'friends/ids';
      twitteroauth_row($method, $connection-&gt;get($method), $connection-&gt;http_code);
  
      /* friends/ids */
      $method = 'friends/ids';
      twitteroauth_row($method, $connection-&gt;get($method), $connection-&gt;http_code);
  
  
      /**
       * Account Methods.
       */
      twitteroauth_header('Account Methods');
  
      /* account/verify_credentials */
      $method = 'account/verify_credentials';
      twitteroauth_row($method, $connection-&gt;get($method), $connection-&gt;http_code);
  
      /* account/rate_limit_status */
      $method = 'account/rate_limit_status';
      twitteroauth_row($method, $connection-&gt;get($method), $connection-&gt;http_code);
  
      /* account/update_profile_colors */
      $parameters = array('profile_background_color' =&gt; 'fff');
      $method = 'account/update_profile_colors';
      twitteroauth_row($method, $connection-&gt;post($method, $parameters), $connection-&gt;http_code, $parameters);
  
      /* account/update_profile */
      $parameters = array('location' =&gt; 'Teh internets');
      $method = 'account/update_profile';
      twitteroauth_row($method, $connection-&gt;post($method, $parameters), $connection-&gt;http_code, $parameters);
  
  
  
  
      /**
       * OAuth Methods.
       */
      twitteroauth_header('OAuth Methods');
  
      /* oauth/request_token */
      $oauth = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
      twitteroauth_row('oauth/r
  
  eqeust_token', $oauth-&gt;getRequestToken(), $oauth-&gt;http_code);
  </code></pre>