twitter-video
Easily posts native video to twitter's video API.
Last updated 5 years ago by bret .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install twitter-video 
SYNC missed versions from official npm registry.

twitter-video

npm travis

Posts native video to twitter's video API.

Install

npm install twitter-video

Usage

var twitterVideo = require('twitter-video')
var Twit = require('twit')

var oauth = {
  consumer_key: '123',
  consumer_secret: '123',
  access_token: '123',
  access_token_secret: '123'
}

var T = Twit(oauth)
var PATH = '/path/to/video.mp4'

twitterVideo.fromFile(PATH, oauth, function (err, media_id) {
  // Now you have a media ID you can post with a tweet
  var params = {status: 'yolo', media_ids: [ media_id ]}
  T.post('statuses/update', params, function post (err, data, res) {
    // Tweet with video is live
  })
})

var twitterStream = twitterVideo(oauth)
var videoStream = fs.createWriteStream(PATH)

twitterStream.on('finish', function() {
  twitterStream.on('media_id', function(media_id) {
    var params = {status: 'so nice i posted it twice', media_ids: [ media_id ]}
    T.post('statuses/update', params, function post (err, data, res) {
      // Tweet with video is live
    })
  })
})

videoStream.pipe(twitterStream)

CLI

npm i -g twitter-video

Installing this globally gives you access to the twitter-video command:

$ twitter-video
Uploads .mp4 video to twitter with a status updates
Usage: twitter-video [options]
    --config              configure your API keys
    --video, -v           path to mp4 file e.g. '~/myVideo.mp4' (requires -s)
    --status, -s          twitter status text e.g. 'this is a tweet yolo' (requires -v)

Before you can post videos to twitter, you need to configure your oAuth keys.

  1. Visit: https://apps.twitter.com
  2. Create a new app. This requires that a cell number is added to your twitter account.
  3. Generate an access token on the "Keys and Access Tokens" tab

Next configure twitter-video

$ twitter-video --config
? Consumer Key 123
? Consumer Secret ***
? Access Token 123
? Access Token Secret ***
Attention: Secret API keys saved to /Users/username/.config/twitter-video
Ready to Send!

Now you can post a tweet with a native video!

$ twitter-video -v DRQCQaiww7XlAYJP.mp4 -s 'engage'
Post created at: https://twitter.com/twittername/status/624602234223865857

Contributing

Contributions welcome! Please read the contributing guidelines first.

Changelog

See CHANGELOG.md for news and updates.

License

ISC

Current Tags

  • 2.0.0                                ...           latest (5 years ago)

8 Versions

  • 2.0.0                                ...           5 years ago
  • 1.0.7                                ...           5 years ago
  • 1.0.6                                ...           5 years ago
  • 1.0.5                                ...           5 years ago
  • 1.0.4                                ...           5 years ago
  • 1.0.2                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 1
Last Month 1
Dependencies (12)
Dev Dependencies (3)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |