Skip to content

Instantly share code, notes, and snippets.

@Hillsie
Created December 23, 2018 13:32
Show Gist options
  • Save Hillsie/588944a25060582d886928dddd82e0da to your computer and use it in GitHub Desktop.
Save Hillsie/588944a25060582d886928dddd82e0da to your computer and use it in GitHub Desktop.
Twitter API call with native https NodeJS
const http = require("https");
// prettier-ignore
const options = {
"method": "GET",
"hostname": "api.twitter.com",
"port": 443,
"path": "/1.1/collections/entries.json?id=custom-90708098097098-fake",
"headers": {
"authorization":`OAuth oauth_consumer_key="yourtwitterconsumerkey",oauth_token="yourregisteredtwittertoken", 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(body.toString());
});
});
req.end();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment