Skip to content

Instantly share code, notes, and snippets.

@jcipriano
Last active March 5, 2016 21:50
Show Gist options
  • Save jcipriano/fb219f04ffeeebf15dea to your computer and use it in GitHub Desktop.
Save jcipriano/fb219f04ffeeebf15dea to your computer and use it in GitHub Desktop.
Post a Tweet with the Twit Node.js module.
var Twit = require('twit')
var twitter = new Twit({
consumer_key: '',
consumer_secret: '',
access_token: '',
access_token_secret: ''
});
var filePath = 'path/to/video/file'
twitter.postMediaChunked({ file_path: filePath }, function (err, data, response) {
console.log(data);
var params = {
status: 'Post from node.js script.',
media_ids: [data.media_id_string]
}
twitter.post('statuses/update', params, function (err, data, response) {
console.log(data)
});
});
@jcipriano
Copy link
Author

npm install twit --save

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