GithubHelp home page GithubHelp logo

twit's People

Contributors

alexwhitman avatar amandeepmittal avatar angelxmoreno avatar azat-io avatar boodoo avatar chandler avatar conradoplg avatar egtoney avatar freethejazz avatar haroonabbasi avatar justinmichaelvieira avatar katanacrimson avatar lpinca avatar mahnunchik avatar matomesc avatar matteoagosti avatar maziyarpanahi avatar naramsim avatar ohcrider avatar pdehaan avatar raine avatar rhysd avatar siyfion avatar stefanbohacek avatar the-bobo avatar tigerpfleger avatar ttezel avatar vnglst avatar volox avatar williamcoates avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

twit's Issues

Proxy support

Hi!

Twit is very cool indeed. However, I seem to have a problem in dev environment and I should use http(s) proxies. This doesn't connect and I think it's because the system proxies are not recognized by node.js. Any chance to add support for proxies (maybe optional params through conf)?

Twitter API Connection Errors?

I am having a problem when the Twitter API is down, my whole application crash.
Is there any standar way to deal with connection errors?

Thanks!

Not tweeting?

So, following your basic example, I worked this code into an app I've written:

//Twitter
global.mTwitOn                  = true; //Whether or not twitter functions are enabled
global.mTwitTimeout             = 20;       //How often [in minutes] the bot can tweet
global.mTwitKey                 = "xx";     //Consumer Key for Twitter
global.mTwitSecret              = "xx";     //Consumer Secret for Twitter
global.mTwitToken               = "xx-xx";      //Access Token for Twitter
global.mTwitTokenSecret         = "xx";     //Access Secret for Twitter

if (mTwitOn) global.mTwit = require("twit");

if (mTwitKey) {
    Log("Connecting to Twitter");
    global.mTwitter = new mTwit({
        consumer_key:         mTwitKey
      , consumer_secret:      mTwitSecret
      , access_token:         mTwitToken
      , access_token_secret:  mTwitTokenSecret
    });
    global.mLastTweeted = null;
    Log("Done");
}

And this is the function to tweet:

callback: function (pUser, pText) {
        if (!mTwitOn) return;
        var sAge = Date.now() - mLastTweeted;
        var sAge_Minutes = sAge / 60000; 
        if(sAge_Minutes < mTwitTimeout) return Speak(pUser, mTweetSpam, SpeakingLevel.Misc, [['{twitime}', mTwitTimeout]], true);
        if (!pText) {
            if (!mCurrentDJ) return;
            mTwitter.post('statuses/update', {
             status: 'Hello World' 
            }, function(err, reply) {});
            mLastTweeted = Date.now();
            return Speak(pUser, mConfirmTweet, SpeakingLevel.Misc);
        }

Those are all spaced out, I'm only posting the relevant code
All of my code works [my Speak function and whatnot, and I'm not getting any errors, but I'm checking the twitter account I'm connected to, and I'm not getting any tweets showing up.

posting replies to tweets

Hey sir, I'm trying to make replies, i've tried putting in_reply_to_status_id in the params, but it doesn't seem to be working.

My post looks like this:

T.post('statuses/update', { in_reply_to_status_id: 206921984414724100,  status: '@ABCDominique Great tweet, that.' }, function(err, reply) {
// things
      });

Any ideas?

npm ls shows bundled oauth dep as "extraneous"

Perhaps this should be listed both under bundledDependencies and dependencies?

katana@serenity ~/repos/twit/
$ npm ls
[email protected] /home/katana/repos/twit
├── [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ └─┬ [email protected]
│   ├── [email protected]
│   └─┬ [email protected]
│     └─┬ [email protected]
│       ├─┬ [email protected]
│       │ ├── [email protected]
│       │ └─┬ [email protected]
│       │   └── [email protected]
│       └── [email protected]
└── [email protected] extraneous

npm ERR! extraneous: [email protected] /home/katana/repos/twit/node_modules/oauth
npm ERR! not ok code 0

Can't get site streams to work

Hi,

This likely isn't a bug, but just in case I thought I'd ask.

I can get 'user' and public timeline streams to work no problem. But I can't seem to get site streams to work. Have you tested this and gotten it to operate correctly? If so is there something I am doing wrong that is preventing me from getting any events?

Here's what I'm doing...

-Creating an instance of Twit
-Using the app owner's token/secret as well as the app's consumer key/secret
-I starting a 'site' stream as below following users that have authenticated with my app

T.stream('site', {'follow': userIds.join(',')}, function (stream) {
stream.on('tweet', function (tweet) {
console.log(tweet);
}
})

But I get nothing when I tweet from one of my test user accounts. If however, I change 'site' to 'user' or 'statuses/filter', I get the update right away.

What am I doing wrong? Thanks in advance for your help and thanks for making this awesome module.

errors parsing twitter response - twit dispatching non-tweet user stream events as tweets

error parsing twitter response. not sure why, guessing it's because of the \r\n contained in the bio? can't really tell. jsonlint doesn't see anything wrong with it either...

This is grabbed out of stderr as well, if that helps.

Error: Error parsing twitter reply: `{"event":"follow","created_at":"Sun Feb 10 03:17:00 +0000 2013","target":{"id":561658570,"default_profile_image":false,"profile_background_image_url":"http:\/\/a0.twimg.com\/profile_background_images\/619085747\/2x47kys21qzszs8fg9ko.jpeg","friends_count":28,"favourites_count":4,"profile_link_color":"009999","profile_background_image_url_https":"https:\/\/twimg0-.akamaihd.net\/profile_background_images\/619085747\/2x47kys21qzszs8fg9ko.jpeg","utc_offset":-21600,"screen_name":"Meido_chu","is_translator":false,"followers_count":108,"name":"Media","lang":"en","profile_use_background_image":true,"created_at":"Tue Apr 24 02:25:12 +0000 2012","profile_text_color":"333333","notifications":false,"protected":false,"id_str":"561658570","statuses_count":1374,"url":null,"contributors_enabled":false,"default_profile":false,"profile_sidebar_border_color":"EEEEEE","time_zone":"Central Time (US & Canada)","geo_enabled":false,"verified":false,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/2949476469\/8e1d977154551ecdba72c713f18b7ad3_normal.jpeg","following":true,"profile_image_url_https":"https:\/\/twimg0-.akamaihd.net\/profile_images\/2949476469\/8e1d977154551ecdba72c713f18b7ad3_normal.jpeg","profile_background_tile":true,"listed_count":2,"profile_sidebar_fill_color":"EFEFEF","location":"In jail","follow_request_sent":false,"description":"Jailed account of @MilitarMaid","profile_background_color":"131516"},"source":{"id":517142024,"default_profile_image":true,"profile_background_image_url":"http:\/\/a0.twimg.com\/images\/themes\/theme14\/bg.gif","friends_count":8,"favourites_count":63,"profile_link_color":"009999","profile_background_image_url_https":"https:\/\/twimg0-.akamaihd.net\/images\/themes\/theme14\/bg.gif","utc_offset":-21600,"screen_name":"_lithion","is_translator":false,"followers_count":21,"name":"Katy","lang":"en","profile_use_background_image":false,"created_at":"Wed Mar 07 02:49:36 +0000 2012","profile_text_color":"333333","notifications":false,"protected":true,"id_str":"517142024","statuses_count":9517,"url":null,"contributors_enabled":false,"default_profile":false,"profile_sidebar_border_color":"FFFFFF","time_zone":"Central Time (US & Canada)","geo_enabled":false,"verified":false,"profile_image_url":"http:\/\/a0.twimg.com\/sticky\/default_profile_images\/default_profile_0_normal.png","following":false,"profile_image_url_https":"https:\/\/twimg0-.akamaihd.net\/sticky\/default_profile_images\/default_profile_0_normal.png","profile_background_tile":true,"listed_count":0,"profile_sidebar_fill_color":"DDEEF6","profile_banner_url":"https:\/\/twimg0-.akamaihd.net\/profile_banners\/517142024\/1357962753","location":null,"follow_request_sent":false,"description":"They say that even starlight takes time to travel to and fro.\r\n\r\nDon't rely on another's twilight; find your own way forward. \r\n\r\nShine...shine...SHINE!","profile_background_color":"9B1414"}}`

'connect' event doesn't fire on stream initialization

Consider the following test case:

var stream = T.stream('statuses/filter', { track: 'BarackObama'});

stream.on('connect', function (req) {
  // Doesn't work because the event is emitted before the listener starts to listen
});

If you stop and start again the stream, then the 'connect' event is correctly handled.
What about removing the automatic start and call it manually?

Warning: may need to force use of SSLv3 on some systems for https twitter connections

For some reason, I had an install (on my own server, running Arch) suddenly stop working after restarting the twit-based client I had running - after a bit of work, found it was due to SSL hooliganery.

Symptom is that of a constant reconnection attempts, progressively getting longer (while making no connection in the end), with no real error shown by twit, nor with any hope of making a connection. You can confirm if this is the same problem if - when you try firing a curl request to twitter's API, you're given a curl ssl error similar to curl: (35) error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure. If this is the case, retry the curl request with the -3 flag and see if you get an HTTP 401 response from twitter. If you do, see below for the solution.

Solution:

https.globalAgent.options.secureProtocol = 'SSLv3_method'

Ugly solution, I know. I'm trying to see if this is due to a package update on my end - possibly relating to openssl.

Possible culprits include:

[2013-02-16 13:52] upgraded curl (7.28.1-1 -> 7.29.0-2)
[2013-02-16 13:52] upgraded gnutls (3.1.7-1 -> 3.1.8-1)
[2013-02-16 13:52] upgraded nodejs (0.8.18-2 -> 0.8.19-1)
[2013-02-16 13:52] upgraded openssl (1.0.1.c-1 -> 1.0.1.e-1)

error timestamp

Hi..I'm getting a error about timestamp, apparently (i did a request for twitter time server) and my machine is 5 hour delayed with the twitter service...I change the time but it doesn't works...now..I read here https://dev.twitter.com/discussions/686 than I can change the oauth_timestamp, is possible do it with twit or I need change the source code :S ...I'm pretty newbie with the twitter api..so..if you can help me I appreciate it :D...

Different results in search/tweets and at twitter.com

I get different results by using "search/tweets" and at twitter.com.
What can be the reason for this behavior?

var Twit = require('twit');
var T = new Twit({
    consumer_key: '...',
    consumer_secret: '...',
    access_token: '...',
    access_token_secret: '...'
});
//  search twitter for all tweets containing the word 'banana' since Nov. 11, 2011
T.get('search/tweets', { q: query + ' since:2006-11-11', count: 100 }, function (err, reply) {
    callBack(null, reply.statuses);
});

Stream authenticating, Post not.

I'm probably doing something stupid, but, I'm able to use the streaming API just fine, but when I try to make a post, the err is:

err:
{ statusCode: 401,
data: '{"error":"Could not authenticate with OAuth.","request":"/1/statuses/update.json?status=Test"}',

Here's the code I'm trying:
T.post('statuses/update', { status: 'Test' }, function(err, reply) {
console.log(err);
});

Can I not be currently streaming with my auth and also make posts at the same time possibly?

twit stream() API, It's not working on RHEL 5.3, but it's working on Windows Platform very well.

Hi,

The following is my testing sample code:

var stream2 = T.stream('user');

stream2.on('tweet', function (tweet) {

console.log('tweet='+util.inspect(tweet, null, null));

});

stream2.on('connect', function (request) {

//console.log('connect='+util.inspect(request, null, null));
console.log('connect');

});

stream2.on('reconnect', function (request, response, connectInterval) {

console.log('reconnect');

});

stream2.on('disconnect', function (disconnectMessage) {

console.log('disconnect='+util.inspect(disconnectMessage, null, null));

});


It's not working on RHEL 5.3 server.
Test Result is the below.
connect
connect
reconnect
connect
reconnect
connect
reconnect
connect
reconnect
connect
reconnect
connect

It's working on Windows Platform very well.
Test Result is the below.
connect
tweet={ friends: [ 6949902, 215198915 ] }

Please check it out.

Thank you for your help.

Regards,
Thomas Lee

Possible memory leak?

I'm noticing something in a simple application that does an interval tweet through twit - and I'm noticing memory use growing over time fairly steadily, making me think something's not being deallocated or gc'd when it should be.

Rough code (with some redacted for own reasons):

var crypto = require('crypto'),
        twit = require('twit'),
        twitter = new twit({
                consumer_key: '',
                consumer_secret: '',
                access_token: '',
                access_token_secret: ''
        }),
        interval = 15 // interval in minutes

// ---

numbers = function(twitter) {
        this.twitter = twitter
        this.intervalFn = null
}
numbers.prototype.run = function() {
        this.twitter.post('statuses/update', { status: 'TRN {' + this.getNumbers() + '} ENDTRN' }, this.react.bind(this))
}
numbers.prototype.react = function(err, reply) {
        if(err) return this.handleError(err)
        console.log('Tweet: ' + (reply ? reply.text : reply))
}
numbers.prototype.handleError = function(err) {
        console.error('response status:', err.statusCode)
        console.error('data:', err.data)
}
numbers.prototype.getNumbers = function() {
        // redacted
}

// ---

n = new numbers(twitter)
n.run()
n.intervalFn = setInterval(n.run.bind(n), (interval) * 60 * 1000)

After few days, it ends up doubling in memory use - after a week, more than tripling.

Latest pull off of npm has a bug (at least it would not run for me)

You have a typo at the top of this file. It is ./Auth but the file is auth.js so it throws an error which stops crashes node due to require :)

./node_modules/twit/lib/twitter.js

** Old: **
//
// Twitter API Wrapper
//
var Auth = require('./Auth')
, OARequest = require('./oarequest')

** New: **
//
// Twitter API Wrapper
//
var Auth = require('./auth')
, OARequest = require('./oarequest')

Two Issues

First of all examples are not working, randomly they are returning 404 for few situations

second 5 tests were failing on my machine. Don't know y though, following is the output.

✖ 5 of 43 tests failed:

  1. REST API GET statuses/home_timeline:
    AssertionError: "undefined" == true
    at checkTweet (/Users/mohitthakral/Projects/twitterbot/node_modules/twit/tests/rest.js:439:10)
    at /Users/mohitthakral/Projects/twitterbot/node_modules/twit/tests/rest.js:126:7
    at handler (/Users/mohitthakral/Projects/twitterbot/node_modules/twit/lib/oarequest.js:278:12)
    at passBackControl (/Users/mohitthakral/Projects/twitterbot/node_modules/twit/node_modules/oauth/lib/oauth.js:367:11)
    at IncomingMessage. (/Users/mohitthakral/Projects/twitterbot/node_modules/twit/node_modules/oauth/lib/oauth.js:386:9)
    at IncomingMessage.EventEmitter.emit (events.js:117:20)
    at _stream_readable.js:920:16
    at process._tickCallback (node.js:415:13)

  2. REST API GET statuses/mentions_timeline:
    AssertionError: "undefined" == true
    at checkTweet (/Users/mohitthakral/Projects/twitterbot/node_modules/twit/tests/rest.js:439:10)
    at /Users/mohitthakral/Projects/twitterbot/node_modules/twit/tests/rest.js:137:7
    at handler (/Users/mohitthakral/Projects/twitterbot/node_modules/twit/lib/oarequest.js:278:12)
    at passBackControl (/Users/mohitthakral/Projects/twitterbot/node_modules/twit/node_modules/oauth/lib/oauth.js:367:11)
    at IncomingMessage. (/Users/mohitthakral/Projects/twitterbot/node_modules/twit/node_modules/oauth/lib/oauth.js:386:9)
    at IncomingMessage.EventEmitter.emit (events.js:117:20)
    at _stream_readable.js:920:16
    at process._tickCallback (node.js:415:13)

  3. REST API GET direct_messages:
    AssertionError: "undefined" == true
    at Object.checkDm (/Users/mohitthakral/Projects/twitterbot/node_modules/twit/tests/rest.js:454:10)
    at /Users/mohitthakral/Projects/twitterbot/node_modules/twit/tests/rest.js:234:15
    at handler (/Users/mohitthakral/Projects/twitterbot/node_modules/twit/lib/oarequest.js:278:12)
    at passBackControl (/Users/mohitthakral/Projects/twitterbot/node_modules/twit/node_modules/oauth/lib/oauth.js:367:11)
    at IncomingMessage. (/Users/mohitthakral/Projects/twitterbot/node_modules/twit/node_modules/oauth/lib/oauth.js:386:9)
    at IncomingMessage.EventEmitter.emit (events.js:117:20)
    at _stream_readable.js:920:16
    at process._tickCallback (node.js:415:13)

  4. streaming API events direct_message event:
    Error: timeout of 30000ms exceeded
    at null. (/Users/mohitthakral/Projects/twitterbot/node_modules/twit/node_modules/mocha/lib/runnable.js:167:14)
    at Timer.listOnTimeout as ontimeout

  5. user events friends:
    AssertionError: "undefined" == true
    at checkFriendsMsg (/Users/mohitthakral/Projects/twitterbot/node_modules/twit/tests/user-stream.js:12:5)
    at OARequest. (/Users/mohitthakral/Projects/twitterbot/node_modules/twit/tests/user-stream.js:25:13)
    at OARequest.EventEmitter.emit (events.js:95:17)
    at null. (/Users/mohitthakral/Projects/twitterbot/node_modules/twit/lib/oarequest.js:58:42)
    at EventEmitter.emit (events.js:95:17)
    at Parser.parse (/Users/mohitthakral/Projects/twitterbot/node_modules/twit/lib/parser.js:41:16)
    at IncomingMessage. (/Users/mohitthakral/Projects/twitterbot/node_modules/twit/lib/oarequest.js:138:21)
    at IncomingMessage.EventEmitter.emit (events.js:95:17)
    at IncomingMessage. (stream_readable.js:746:14)
    at IncomingMessage.EventEmitter.emit (events.js:92:17)
    at emitReadable
    (_stream_readable.js:408:10)
    at emitReadable (_stream_readable.js:404:5)
    at readableAddChunk (_stream_readable.js:165:9)
    at IncomingMessage.Readable.push (_stream_readable.js:127:10)
    at HTTPParser.parserOnBody as onBody
    at CleartextStream.socketOnData as ondata
    at CleartextStream.read as _read
    at CleartextStream.Readable.read (_stream_readable.js:320:10)
    at EncryptedStream.write as _write
    at doWrite (_stream_writable.js:221:10)
    at writeOrBuffer (_stream_writable.js:211:5)
    at EncryptedStream.Writable.write (_stream_writable.js:180:11)
    at write (_stream_readable.js:583:24)
    at flow (_stream_readable.js:592:7)
    at Socket.pipeOnReadable (stream_readable.js:624:5)
    at Socket.EventEmitter.emit (events.js:92:17)
    at emitReadable
    (_stream_readable.js:408:10)
    at emitReadable (_stream_readable.js:404:5)
    at readableAddChunk (_stream_readable.js:165:9)
    at Socket.Readable.push (_stream_readable.js:127:10)
    at TCP.onread (net.js:526:21)

npm ERR! weird error 5
npm ERR! not ok code 0

destroy tweet is not working

I use this code
T.post('statuses/destroy',{id: tweet_id}, function(err, reply) {
console.log(err);
})
and get
{ statusCode: 404,
data: '{"errors":[{"message":"Sorry, that page does not exist","code":34}]}',
twitterReply: '{"errors":[{"message":"Sorry, that page does not exist","code":34}]}' }

OARequest.prototype.end - Potentially misleading exception message.

Was thinking that the error message shown here is potentially misleading when its the callback that caused the exception, and in such situations losing the original exception could be a problem when your debugging:

'''
try {
var parsed = JSON.parse(raw);
return callback(null, parsed);
} catch(e) {
var error = new Error('twitter reply is not a valid JSON string.');
error.twitterReply = raw;
return callback(error, null);
}
'''

Error in Twit ID

Looks like because of the way Node.js handle big integers, there is a problem with the Twit ID you received.

I am getting

id_str: '249992494792818688',
id: 249992494792818700,

Any idea of how to solve it?

Question: access to rate limit information when using REST API

When you call the Twitter REST API it provides rate limiting headers in the response. See: https://dev.twitter.com/docs/rate-limiting-faq#checking

This information looks like it's actually a bit out of date. It looks like the headers are:

  • x-rate-limit-limit
  • x-rate-limit-remaining
  • x-rate-limit-reset

e.g.

{ 'x-access-level': 'read-write',
     'content-type': 'application/json;charset=utf-8',
     'last-modified': 'Sun, 13 Jan 2013 17:29:54 GMT',
     expires: 'Tue, 31 Mar 1981 05:00:00 GMT',
     pragma: 'no-cache',
     'cache-control': 'no-cache, no-store, must-revalidate, pre-check=0, post-check=0',
     'set-cookie':
      [ 'guest_id=v1%3A135809819409692422; Expires=Tue, 13-Jan-2015 17:29:54 GMT; Path=/; Domain=.twitter.com',
        'lang=en' ],
     'x-transaction': '53a1e38afc6f4623',
     'x-frame-options': 'SAMEORIGIN',
     status: '200 OK',
     date: 'Sun, 13 Jan 2013 17:29:54 GMT',
     'content-length': '4171',
     'x-rate-limit-limit': '180',
     'x-rate-limit-remaining': '175',
     'x-rate-limit-reset': '1358098325',
     server: 'tfe',
     connection: 'close' }

This information might be quite useful to those using this library e.g. knowing when to back off calls when approaching the rate limit. Any thoughts on providing access to this? It could be as simple as passing on the response object as part of the callback here:
https://github.com/ttezel/twit/blob/master/lib/oarequest.js#L199

A developer could then just access the third parameter on any get or post call e.g.

T.get('search/tweets', { q: 'banana since:2011-11-11' }, function(err, reply, response) {
  var rateLimit = response.headers['x-rate-limit-limit'];
});

Or there may be a nicer solution? Any preferences or thoughts? Happy to submit a pull request if others think this would be handy. I do :)

Update:

It looks like you can't rely on these headers always being present. They are their for search/tweet but not there for others e.g. friendships/destroy. So, it seems inconsistent.

How do you post on behalf of user?

I'm not seeing anything glaringly obvious in the README on how to post a status on behalf of another user. According to twitter there has to be a 'Sign in with Twitter' feature to achieve this.

Please help! Thanks in advance!

[Streaming Api] Cannot search by bounding box AND keyword.

If I had "track" to my stream that is currently returning only San Francisco tweets, it starts returning me tons of tweets without geo-data.

Maybe this is intentional, but it's not in the documentation, which implies you can do "track" and "language" filters... so I'm led to believe I should be able to do "track" and "locations" right?

Thanks in advance!

Streaming API silently not working

Hello there, (yesterday it worked, but I tried today and it didnt, I didnt change anything in the code),

here is my code:

var Twit = require('twit');
var T = new Twit({
consumer_key: 'vroFy2FvOR8En7saib1A4Q'
, consumer_secret: '**'
, access_token: '10818002-
'
, access_token_secret: '*'
});

var stream = T.stream('statuses/sample');
stream.on('tweet', function (tweet) {
console.log(tweet);
});
stream.on('error', function (tweet) {
console.log(tweet);
});

stream.on('limitation', function (tweet) {
console.log(tweet);
});

if I do node twit.js I get nothing and the process ends, any hints?

stream callbacks on reconnect

Hi!

Just a question, do we need to add again event callbacks after a reconnection? I mean

  1. stream.stop()
  2. stream.on('tweet', callback_function);
  3. stream.start()

I've noticed that, after stop / start, callbacks are not fired. Don't know if I'm doing something wrong, btw!

Follow commas

How do you get the comma separated list for following people to work? The commas seem to get escaped and twitter does not recognize the individual user ids. Also, I see you use GET for the streaming api would it not be better to use POST as 5000 follow ids could become a problem in the URL.

https://dev.twitter.com/docs/api/1/post/statuses/filter

Reply to tweet is not working

The following code should result in a reply to a post, but it does not. The tweet goes through successfully, but not as a reply. The id used below was taken from the id_str property on the user deacondesperado's tweet. I've included his handle in the status as the api requires.

Any thoughts?

var data = {
    status: "test with @deacondesperado",
    in_reply_to_status_id: 312188548927348737
};
twitter.post "statuses/update", data, function (err, res) {
});

Stream disconnect event not firing.

I have a lightweight little bot running and heavily relying on the Stream API. I notice that once a day my bot disconnects with the following message:

events.js:48
        throw arguments[1]; // Unhandled 'error' event
                       ^
Error: Connection lost: The server closed the connection.
    at Protocol.end (/var/www/vhosts/iweigh.net/bot/node_modules/mysql/lib/protocol/Protocol.js:73:13)
    at Socket.onend (stream.js:80:10)
    at Socket.emit (events.js:88:20)
    at TCP.onread (net.js:388:51)

Here's the code I'm using. From the README, this should be catching the disconnect from Twitter and gracefully exiting (and at least logging my Stream Disconnection message).

stream.on('disconnect', function(data) {
        console.log(data);
        console.log('[TWITTER] Stream disconnection!');
});

Any thoughts?

favorites/create gives "statusCode 401" and "code 32"

I get "Could not authenticate you" error when trying to post a fav, I reviewed if the code and access tokens, they are working doing a post "statuses/update" successfully, but with the fav I wasn't lucky.

  {
      "statusCode": 401,
      "data": "{\"errors\":[{\"message\":\"Could not authenticate you\",\"code\":32}]}",
      "twitterReply": "{\"errors\":[{\"message\":\"Could not authenticate you\",\"code\":32}]}"
  }

Search and count

Hi, is there a way to get more than 15 tweets from search? In Twitter documentation user supposed to use "count". I tried it with twit but it does not work.

stall warnings

er.com/docs/streaming-apis/parameters

Where can I hook this event?

Bad type checks

Was perusing your code and noticed a couple of potential bugs. Just giving a friendly heads up that there a couple of type checks that won't work the way one would expect in JavaScript here and here.

> typeof null
"object"

Error: Error parsing twitter reply

Parser crashed on this tweet JSON:

{"created_at":"Sun Dec 16 09:57:16 +0000 2012","id":280250229876486144,"id_str":"280250229876486144","text":"\u041a\u043e\u0442 \u0438 \u043b\u0435\u043d\u0438\u0432\u0438\u0446\u0430 @ \u043f\u0440\u0438\u043d\u0446\u0435\u0441\u044c\u044f \u043d\u043e\u0440\u0430 http://t.co/tdX0aNSq","source":"\u003ca href="http://instagr.am" rel="nofollow"\u003eInstagram\u003c/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":209665061,"id_str":"209665061","name":"\u0425\u0430\u0448\u0438\u043c\u043e\u0432\u0430 \u0415\u0432\u0433\u0435\u043d\u0438\u044f","screen_name":"Ohh_jane","location":"","url":"http://www.formspring.me/SuperZhenya","description":"\u0442\u044b \u0432\u043e\u043e\u0431\u0449\u0435 \u043e \u0447\u0435\u043c?","protected":false,"followers_count":58,"friends_count":36,"listed_count":0,"created_at":"Fri Oct 29 17:05:30 +0000 2010","favourites_count":217,"utc_offset":25200,"time_zone":"Novosibirsk","geo_enabled":true,"verified":false,"statuses_count":2028,"lang":"ru","contributors_enabled":false,"is_translator":false,"profile_background_color":"C0DEED","profile_background_image_url":"http://a0.twimg.com/profile_background_images/673275719/29a8bb4a29f5fc308bee9aeac18fc1d7.jpeg","profile_background_image_url_https":"https://si0.twimg.com/profile_background_images/673275719/29a8bb4a29f5fc308bee9aeac18fc1d7.jpeg","profile_background_tile":true,"profile_image_url":"http://a0.twimg.com/profile_images/2665901791/791b0a9e7936add9b00ddc1f3fcbb1cb_normal.jpeg","profile_image_url_https":"https://si0.twimg.com/profile_images/2665901791/791b0a9e7936add9b00ddc1f3fcbb1cb_normal.jpeg","profile_banner_url":"https://si0.twimg.com/profile_banners/209665061/1349017512","profile_link_color":"0084B4","profile_sidebar_border_color":"FFFFFF","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":true,"default_profile":false,"default_profile_image":false,"following":null,"follow_request_sent":null,"notifications":null},"geo":{"type":"Point","coordinates":[54.99534607,82.89186096]},"coordinates":{"type":"Point","coordinates":[82.89186096,54.99534607]},"place":{"id":"679cf8e8e64889c3","url":"http://api.twitter.com/1/geo/id/679cf8e8e64889c3.json","place_type":"city","name":"\u041d\u043e\u0432\u043e\u0441\u0438\u0431\u0438\u0440\u0441\u043a","full_name":"\u041d\u043e\u0432\u043e\u0441\u0438\u0431\u0438\u0440\u0441\u043a, \u041d\u043e\u0432\u043e\u0441\u0438\u0431\u0438\u0440\u0441\u043a","country_code":"RU","country":"\u0420\u043e\u0441\u0441\u0438\u044f","bounding_box":{"type":"Polygon","coordinates":[[[82.750613,54.803186],[82.750613,55.199782],[83.160763,55.199782],[83.160763,54.803186]]]},"attributes":{}},"contributors":null,"retweet_count":0,"entities":{"hashtags":[],"urls":[{"url":"http://t.co/tdX0aNSq","expanded_url":"http://instagr.am/p/TSwvNVmeuk/","display_url":"instagr.am/p/TSwvNVmeuk/","indices":[32,52]}],"user_mentions":[]},"favorited":false,"retweeted":false,"possibly_sensitive":false,"lang":"ru"}

http://jsonlint.com/ said it is valid JSON

Çoklu status/filter stream

Selamlar,

Tek bir connection üzerinden birden fazla status/filter stream yapmaya çalışıyorum ancak başarılı olmuyor. Bu ya da buna en yakın bir kullanım örneği gösterebilir misiniz?

Teşekkürler.

dependency 'mocha' out of date

Mocha dependency is badly out of date and needs updated desperately.

npm WARN engine [email protected]: wanted: {"node":">= 0.4.x < 0.7.0"} (current: {"node":"v0.8.19","npm":"1.2.10"})
npm WARN unmet dependency /home/katana/repos/rumble/node_modules/twit/node_modules/mocha requires commander@'0.3.2' but will load
npm WARN unmet dependency /home/katana/repos/rumble/node_modules/commander,
npm WARN unmet dependency which is version 1.1.1
npm WARN engine [email protected]: wanted: {"node":">= 0.4.x < 0.7.0"} (current: {"node":"v0.8.19","npm":"1.2.10"})
:katana@serenity ~/
$ npm info mocha version
npm http GET https://registry.npmjs.org/mocha
npm http 200 https://registry.npmjs.org/mocha
1.8.1

:katana@serenity ~/
$ npm info mocha dependencies

{ commander: '0.6.1',
  growl: '1.7.x',
  jade: '0.26.3',
  diff: '1.0.2',
  debug: '*',
  mkdirp: '0.3.3',
  ms: '0.3.0' }

Stream with a lang filter

I know that there is an attribute lang in the Twitter API (user,lang). Would it be possible to stream the api on hashtags and lang ? By passing another arrays of params maybe ?

stream: add event "friends"

On initial connect, I'm seeing a "tweet" event being dispatched with just a "friends" property (array) - perhaps this should be added into this bit as a new event, considering it's not a "real" tweet?

(Note: I'm using this as t.stream's second arg: { with: 'followings', replies:'all' })

Cache

Since Twitter limits request at 350 reqs/h, is there a way to cache request for a couple of hours or something?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.