jdub / node-twitter Goto Github PK
View Code? Open in Web Editor NEWThis project forked from technoweenie/twitter-node
[ARCHIVED] Twitter API client library for node.js
Home Page: https://github.com/desmondmorris/node-twitter
License: Other
This project forked from technoweenie/twitter-node
[ARCHIVED] Twitter API client library for node.js
Home Page: https://github.com/desmondmorris/node-twitter
License: Other
npm info it worked if it ends with ok
npm info using [email protected]
npm info fetch http://registry.npmjs.org/twitter/-/twitter-0.1.16.tgz
npm info fetch http://registry.npmjs.org/cookie/-/cookie-0.1.5.tgz
npm info fetch http://registry.npmjs.org/oauth/-/oauth-0.9.0.tgz
npm info install [email protected]
npm info install [email protected]
npm info install [email protected]
npm ERR! Failed unpacking the tarball.
npm ERR! This is very rare. Perhaps the 'gzip' or 'tar' configs
npm ERR! are set improperly?
npm ERR!
npm ERR! install failed Error: Failed gzip "--decompress" "--stdout" "/usr/local/lib/node/.npm/.cache/twitter/v0.1.16/package.tgz"
npm ERR! install failed exited with 1
npm ERR! install failed at ChildProcess. (/usr/local/lib/node/.npm/npm/0.2.3-3/package/lib/utils/exec.js:41:19)
npm ERR! install failed at ChildProcess.emit (events.js:67:17)
npm ERR! install failed at Socket. (child_process.js:172:12)
npm ERR! install failed at Socket.emit (events.js:64:17)
npm ERR! install failed at Array.2 (net.js:825:12)
npm ERR! install failed at EventEmitter._tickCallback (node.js:126:26)
npm info install failed rollback
npm info not installed twitter,v0.1.16
npm info not installed cookie,0.1.5
npm info not installed oauth,0.9.0
npm info install failed rolled back
npm ERR! Error: Failed gzip "--decompress" "--stdout" "/usr/local/lib/node/.npm/.cache/twitter/v0.1.16/package.tgz"
npm ERR! exited with 1
npm ERR! at ChildProcess. (/usr/local/lib/node/.npm/npm/0.2.3-3/package/lib/utils/exec.js:41:19)
npm ERR! at ChildProcess.emit (events.js:67:17)
npm ERR! at Socket. (child_process.js:172:12)
npm ERR! at Socket.emit (events.js:64:17)
npm ERR! at Array.2 (net.js:825:12)
npm ERR! at EventEmitter._tickCallback (node.js:126:26)
npm ERR! npm install
npm ERR! npm install
npm ERR! npm install
npm ERR! npm install
npm ERR! npm install @
npm ERR! npm install @
npm ERR! npm install @
npm ERR!
npm ERR! Can specify one or more: npm install ./foo.tgz bar@stable /some/folder
npm ERR! Installs '.' if no argument supplied
npm ERR! try running: 'npm help install'
npm ERR! Report this entire log at http://github.com/isaacs/npm/issues
npm ERR! or email it to [email protected]
npm not ok
I would like to favorite a tweet with the id. Is this possible? Could you give me an example?
Thanks!
The params object in the get() method is not sent with the OAuth request.
You should process the params and append them as get query params to the url.
It seems like for the post request with parameters within the body (which needs to be done for https://dev.twitter.com/docs/api/1.1/post/statuses/filter) it fails to auth. I'm just getting 401 Error Unauthorized. Any ideas how to get it solved?
for how long will a connection remain open for streaming api? i want to keep it open as long as the script runs (days/months etc)
With valid (verified) secrets and keys and token in config.json, I can't see why this is giving me 401.
Time on server is up to date and in UTC timezone.
Please advise.... Also, which is the correct fork of this project for the npm ?
npm init -y
npm i twitter
"use strict"
var Twitter = require('twitter');
let config = require('./config.json');
var client = new Twitter(config.twitter);
var stream = client.stream('statuses/filter', {track: 'EURO2016'});
stream.on('data', function(tweet) {
console.log(tweet.text);
});
stream.on('error', function(e) {
console.error(e);
console.error(e.stack);
});
When running a script using twitter, npm throws this error: This library has been deprecated. Please use npm install cookies
instead.
I'm guessing this means the lib needs to be rewritten to use the newer cookie lib. I would offer to do it, but I'm a bit of a beginner at node.js as it is!
Hello,
I try to use your code but it doesn't seems to work for Site Stream.
twit.stream('site', {follow:'6253282'}, function(stream) { stream.on('data', function(data) { console.log(util.inspect(data)); }); // Disconnect stream after five seconds setTimeout(stream.destroy, 5000); });
output:
events.js:48 throw arguments[1]; // Unhandled 'error' event
Any help is appreciate.
Thanks,
-A
Sorry if it's already possible, yet I haven't find it.
I would like to subscribe to a user timeline, just as the "statuses/sample" stream example.
API 1 is now deprecated and will be removed on March 2013.
node-twitter currently requires OAuth details.
Sometimes it's unnecessary to authenticate to the API endpoint at all, so it should be possible to do so with node-twitter.
Some endpoints do not implement OAuth, or still use basic auth (and for whatever reason, the user would prefer to use it), so node-twitter should also allow for this.
To have more than one userid connect to the stream, it would nice if the follow param would accept an array as a option
client.stream('statuses/filter', {follow: [749995687, 10613072]}, function(stream) {
stream.on('data', function(tweet) {
console.log(tweet.text);
});
stream.on('error', function(error) {
throw error;
});
});
I dont think it's an issue, but I dont find an example to make it work for my case. I would like to get all tweets geo localized, previously I used the twitter-node with basic auth, and it works fine. But I would like to update it to use oauth and thought to use your package.
I have tried the memory.js example that works fine but when I change the call to this:
twitterStream.stream('statuses/filter', "locations=-180,-90,180,90", function(stream){
//twitterStream.stream('statuses/sample', "locations=-180,-90,180,90", function(stream){
stream.on('data', tweet);
stream.on('error', function(error) { console.log("error : " + error);} );
stream.on('end', function(end) { console.log("end : " + end);} );
});
I just get an "end: undefined"
I have initialized twitterStream like that:
var twitterStream = new Twitter({
consumer_key: config.consumer_key,
consumer_secret: config.consumer_secret,
access_token_key: config.access_token_key,
access_token_secret: config.access_token_secret
});
Any idea ?
Error:
defaults = fs.existsSync( keysPath )
TypeError: Object # has no method 'existsSync'
Does anybody else experience high CPU b/c of this module? I go from 0 to 90% in about 15 minutes. Haven't done any hardcore heap analysis yet, cuz I sort of don't know how yet.
Has any one tested it in node 0.5.10 yet?
In order to support 64bit user IDs, you'll need to store IDs as strings. Assumptions like this will fail:
if (typeof id === 'string')
params.screen_name = id;
else
params.user_id = id;
Hi,
not sure if I am doing something wrong.
I am trying to request the profile information of my "friends". From
https://dev.twitter.com/docs/api/1.1/get/users/lookup
it looks like I need to make 2 requests. From the request to '/users/friends', I get IDs. Then, I need to pass an Array of IDs to fetch the profile information. The idea would be to pass an Array of IDs to:
twit.get('/friends/ids.json', function(d) {
d.ids.slice(1, MAX).forEach(function(id) {
twit.lookupUser(id, function(user) {
// ... could be batch
});
});
});
Any idea how to do this?
Thanks!
There doesn't seem to be a way to close a stream.
I am connecting via socket.io so I would like to close off a stream when a client disconnects.
Hi, I would like to be a collaborator to add the option to do PUT and DELETE operations from your package. We use node-twitter to work with Twitter Ads, for this I dared to add a few lines in your project that they worked and I think that they can serve to other projects.
The changes were the following ones:
In File lib/twitter.js in the section where GET and POST operations are, I add this lines:
Twitter.prototype.put = function(url, params, callback) {
return this.__request('put', url, params, callback);
};
Twitter.prototype.delete = function(url, params, callback) {
return this.__request('delete', url, params, callback);
};
and in the same file in method: Twitter.prototype.__buildEndpoint = function(path, base)
add 'put' and ' delete' strings into next if:
// Pass form data if post, put or delete
if (method === 'post' || method ==='put' || method ==='delete') {
var formKey = 'form';
if (typeof params.media !== 'undefined') {
formKey = 'formData';
}
options[formKey] = params;
}
If you are agree with this changes, you can accept my request and add this few chages. My team will thank you.
I'm noticing an issue when you reach the API rate limiter when creating streams in this bit of code (parser.js):
// We have END?
while ((index = this.buffer.indexOf(Parser.END)) > -1) {
json = this.buffer.slice(0, index);
this.buffer = this.buffer.slice(index + Parser.END_LENGTH);
if (json.length > 0) {
try {
json = JSON.parse(json);
this.emit('data', json);
} catch (error) {
this.emit('error', error);
}
}
}
It appears that the JSON.parse is attempting to parse the error message returned by twitter, which is not JSON:
"Easy there, Turbo. Too many requests recently. Enhance your calm."
This took a bit of time to track down as the error appearing in the console was:
[SyntaxError: Unexpected token E]
It appears that the Twitter June 30th changes may have impacted tweet delivery. Is anyone else seeing delays in POSTs?
When using the node-twitter library in a recent project it failed overnight with the following error:
Error: ECONNREFUSED, Connection refused
at Client._onConnect (net.js:601:18)
at IOWatcher.onWritable as callback
Has the api for twitter changed?
Using createFavorite
twit.createFavorite(tweet_id, function(res){
console.log(res);
console.log('favorited',tweet_id, user.screen_name, data.text);
});
/favorites/create/482615087606530050.json
https://api.twitter.com/1.1/favorites/create/482615087606530050.json null
{ [Error: HTTP Error 404: Not Found]
statusCode: 404,
data: '{"errors":[{"message":"Sorry, that page does not exist","code":34}]}' }
Using .post
twit.post('/favorites/create.json',{id:tweet_id}, function(data){
console.log(data);
console.log('favorited',tweet_id, user.screen_name, data.text);
})
https://api.twitter.com/1.1/favorites/create.json { id: 482616763054444540 }
{ [Error: HTTP Error 404: Not Found]
statusCode: 404,
data: '{"errors":[{"message":"Sorry, that page does not exist","code":34}]}' }
favorited 482616763054444540 guttulus undefined
To determine the validity of the twauth cookie, login() and gatekeeper() currently just check that the cookie exists and has user_id / access_token_secret. Those details may be expired or otherwise invalid, so anything depending on them being correct will fail... it's even worse for apps which don't actually care about the authorisation, just up-to-date authentication!
So: We should only regard twauth as valid immediately after an oauth transaction or, if we've only received a cookie to check, after we make a verifyCredentials call.
Pretty much everything using _getUsingCursor should not do so by default, but there should be a standard suffix or method for making them do so.
The error handling does not function as it should
Listening for
stream.on('error', ... );
is not triggered when there is a connection error. Using incorrect credentials to try to initiate a stream does not trigger any error.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.