项目作者: ArtskydJ

项目描述 :
:bird: A no-nonsense node module for posting tweets
高级语言: JavaScript
项目地址: git://github.com/ArtskydJ/tweet-tweet.git
创建时间: 2015-04-11T00:27:47Z
项目社区:https://github.com/ArtskydJ/tweet-tweet

开源协议:

下载


tweet-tweet

A no-nonsense node module for posting tweets.

Build Status

This is only for updating your Twitter status. This does not get tweets, or stream search results. Images and videos are not supported.

example

  1. var TweetTweet = require('tweet-tweet')
  2. var tweet = TweetTweet({
  3. consumerKey: '...',
  4. consumerSecret: '...',
  5. accessToken: '...',
  6. accessTokenSecret: '...'
  7. })
  8. tweet('Never teach someone how to cartwheel beside a lake. #lessonlearned')
  9. setTimeout(function () {
  10. tweet('That awkward moment when you wake up... Said no one ever.')
  11. }, 60 * 1000)

api

  1. var TweetTweet = require('tweet-tweet')

TweetTweet(auth)

If you don’t know how to get the tokens and secrets from Twitter, see AUTHENTICATION.md for detailed instructions.

  • auth is an object with consumerKey, consumerSecret, accessToken, and accessTokenSecret properties
  • Returns tweet

tweet(status, [cb])

  • status is a string or an object
    • If it is a string, it is the text of your status update.
    • If it is an object, it can have the parameters specified in the Twitter API under the Parameters section.
      • status - Required. The text of your status update. E.g. 'i love my cat. #cats'
      • in_reply_to_status_id - The ID of an existing status that the update is in reply to. Note that the author must be referenced in the status.
      • possibly_sensitive - If the tweet contains nudity, violence, etc. set this to true. Defaults to false.
  • cb(err, response) is an optional callback function. If no callback is given, errors will be swallowed.
    • err is an Error object or null.
    • response is the parsed JSON response. See a sample response in the Twitter API under the Example Result section.
  1. // Status string vs. status object
  2. tweet('i like Twitter')
  3. // Equivalent
  4. tweet({ status: 'i like Twitter' })
  1. // Setting parameters
  2. tweet({
  3. status: 'not for weak stomachs: http://emergency-room-pictures.com',
  4. possibly_sensitive: true
  5. })
  1. tweet({
  2. in_reply_to_status_id: '579328173764014080',
  3. // https://twitter.com/Twitter/status/579328173764014080
  4. status: 'Happy birthday @twitter!'
  5. // Since the status that is being replied to is from the @twitter
  6. // account, then "@twitter" must be included in the status
  7. })
  1. tweet('why is the sky blue?', function (err, res) {
  2. if (err) throw err
  3. console.log(res)
  4. })
  1. tweet({
  2. status: 'People comment "lol" even when they do not laugh.'
  3. }, function (err, res) {
  4. if (err) throw err
  5. console.log(res)
  6. })

install

With npm do:

  1. npm install tweet-tweet

license

MIT