Skip to content

Instantly share code, notes, and snippets.

@jcipriano
Last active November 2, 2017 18:12
Show Gist options
  • Save jcipriano/0ec7dfb1142286faf2c0008eebf752e7 to your computer and use it in GitHub Desktop.
Save jcipriano/0ec7dfb1142286faf2c0008eebf752e7 to your computer and use it in GitHub Desktop.
Accesses and saves to disk an image in a Twitter Direct Message.
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.')
})
@jcipriano
Copy link
Author

npm install request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment