javascriptnode.jstwittertwitter-oauth

Get Twitter Followers


I just want twitter follower count. They make it as hard as possible.

const http = require("https");
 const A = 'vVYgmEsMeHXEjtlb6YJ42O2sD';
 const B = 'vARDHuroFGWIQzpmCm4Q5QGT5uEkrvBwMTGrwOpCFadQGlWDo8';
 const C = 'AAAAAAAAAAAAAAAAAAAAAC29MwEAAAAAEMxXg8OVmsbeDCQjfYXJ4AYGMuU%3DnHerZC38uDxt6gmnJ8265FaC8nU0oBqhHahmxkCtn9EZPH7n8o';
// prettier-ignore
const options = {
  "method": "GET",
  "hostname": "api.twitter.com",
  "port": 443,
  "path": "/1.1/users/lookup.json?screen_name=god",
  "headers": {
    "authorization":`OAuth oauth_consumer_key="${A}",oauth_token="${B}", oauth_signature_method="HMAC-SHA1",oauth_timestamp="atimestame",oauth_nonce="anonceofyourchoic",oauth_version="1.0",oauth_signature="anoauthtweet"`,
    "cache-control": "no-cache"
  }
};
const req = http.request(options, function(res) {
  let chunks = [];

  res.on("data", function(chunk) {
    chunks.push(chunk);
  });

  res.on("end", function() {
    let body = Buffer.concat(chunks);
    console.log('TWITTER SUCKS',body.toString());
  });
});

I keep changing the A and B values to random things from my "app" i created in the twitter developer settings (since i dont see oauth_consumer_key or oauth_token anywhere. I don't even know if that string is right.

Their docs are terrible, please help.


Solution

  • Found the secret hidden hack that lets you easily get your follower count without the horrible API:

    https://cdn.syndication.twimg.com/widgets/followbutton/info.json?screen_names=YOURUSERNAME
    

    a simple request to this and you're done. you're welcome.