title: How to call Twitter v1.1 API in javascript using AJAX
body: <p>Aim - to get the twitter followers of a particular user using javascript</p>
  
  <p>I have tried the below code as a POC- </p>
  
  <pre><code>$(document).ready(function() {
      // Handler for .ready() called.
  
      $.ajax({
          url: "https://api.twitter.com/1.1/followers/ids.json?callback=?",
          type: "GET",
          data: { cursor: "-1", 
                  screen_name: "twitterapi" },
          cache: false,
          dataType: 'json',
  
          success: function(data) { alert('hello!'); console.log(data);},
          error: function(html) { alert(html); },
          beforeSend: setHeader
      });
  
  
      function setHeader(xhr) {
          if(xhr &amp;&amp; xhr.overrideMimeType) {
              xhr.overrideMimeType("application/j-son;charset=UTF-8");
          }
  
          //var nonce = freshNonce();
          //var timestamp = freshTimestamp();
          //var signature = sign(nonce,timestamp);
  
          //alert(signature);
          //alert(accessToken+"-"+consumerKey);
          //alert(oauth_version+"-"+oauth_signature_method);
          xhr.setRequestHeader('Authorization','OAuth');
          xhr.setRequestHeader('oauth_consumer_key', 'HdFdA3C3pzTBzbHvPMPw');
          xhr.setRequestHeader('oauth_nonce', '4148fa6e3dca3c3d22a8315dfb4ea5bb');
          xhr.setRequestHeader('oauth_signature','uDZP2scUz6FUKwFie4FtCtJfdNE%3D');
          xhr.setRequestHeader('oauth_signature_method', 'HMAC-SHA1');
          xhr.setRequestHeader('oauth_timestamp', '1359955650');
          xhr.setRequestHeader('oauth_token', '1127121421-aPHZHQ5BCUoqfHER2UYhQYUEm0zPEMr9xJYizXl');
          xhr.setRequestHeader('oauth_version', '1.0');
      }
  
  });
  </code></pre>
  
  <p>I calculated the signature values from the Twitter OAuth tool ..
  This gives me 400 Bad Request error ....</p>
  
  <p>Please let me know what the problem is...</p>