Last active
November 2, 2017 18:12
-
-
Save jcipriano/0ec7dfb1142286faf2c0008eebf752e7 to your computer and use it in GitHub Desktop.
Accesses and saves to disk an image in a Twitter Direct Message.
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
var request = require('request') | |
var fs = require("fs") | |
// twitter authentication | |
var twitter_oauth = { | |
consumer_key: 'redacted', | |
consumer_secret: 'redacted', | |
token: 'redacted', | |
token_secret: 'redacted' | |
} | |
// update request options | |
request_options = { | |
url: 'redacted', // URL to image in DM | |
oauth: twitter_oauth | |
} | |
// download image | |
request.get(request_options).pipe(fs.createWriteStream('image.jpg')).on('close', function () { | |
console.log('Download complete.') | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
npm install request