Created
December 23, 2018 13:32
-
-
Save Hillsie/588944a25060582d886928dddd82e0da to your computer and use it in GitHub Desktop.
Twitter API call with native https NodeJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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