reneraab / node-twitter-api Goto Github PK
View Code? Open in Web Editor NEWSimple module for using Twitter's API in node.js
License: MIT License
Simple module for using Twitter's API in node.js
License: MIT License
I am requiring the node app at the top of my js file. I get the following error Uncaught TypeError: undefined is not a function
on this line:
this._loading = file;
// Read file and split into lines
var map = {},
content = fs.readFileSync(file, 'ascii'),
How I am importing the file is like so:
var twitterAPI = require('node-twitter-api');
Hi there, wondering if the maintainer(s) of this repo are interested in an overhaul PR. I recently forked this project and converted it from OO/callbacks to functional/promises.
Seeing as this repo is no longer maintained, just wanted to ask if you're open to breathing in some new life. Otherwise I'll just fork it and put my updates there. Let me know!
var twitterAPI = require('node-twitter-api');
var twitter = new twitterAPI({
consumer_key: "removed",
consumer_secret: "removed",
callback: 'http://52.43.53.156:3000'
});
response:
Error getting OAuth request token : [object Object]
statusCode=400
data={"errors":[{"code":215,"message":"Bad Authentication data."}]}
My callback in this code is the same as what i entered in the twitter web interface.
Please update documentation to reflect the proper namespace and their respective types. Specifically the getTimeline namespace and its respective types. Thank You!
I've been looking at the documentation or the code but I can't see a way to close a streem. Is there any?
In my application, I need to make some requests using application-only auth instead of user-specific auth. Is that possible using this library, or are things only wired up for the user-specific version? I see that there's an OAuth endpoint method, but it appears to want an accessToken and accessTokenSecret, so it doesn't seem like the type of thing one would use to bootstrap a bearer token for the app to use for app-only auth...
Unable to get the value for oaut_verifier .As a result of this not able to run the below function which needs the oauth_verifier as a parameter.
Twitter.prototype.getAccessToken = function(requestToken, requestTokenSecret, oauth_verifier, callback) {
this.oa.getOAuthAccessToken(requestToken, requestTokenSecret, oauth_verifier, function(error, oauthAccessToken, oauthAccessTokenSecret, results) {
if (error) {
callback(error);
} else {
console.log("HIIIIII");
callback(null, oauthAccessToken, oauthAccessTokenSecret, results);
}
});
};
Now in the begining of step 3 it is written that he url from step 2 will redirect and provide us with the value for oauth_verifier ,but when we are trying to get the rediret url it is returning us html content and we are not getting a oauth_verifier in that.
hi, I completed the step 2, But the step 3 use the oauth_verifier and i don't know where to get the oauth_verifier value, could you please tell me how to get the oauth_verifier value ?
thank you .
Hello,
I am coding an API that interact with Twitter API but I could not find a way to invalidate token, here's my code :
var accessToken = '...';
var accessSecretToken = '...';
twitter.oauth('invalidate_token', {access_token: accessToken}, accessToken, accessSecretToken, function(err, data, response){
if (err) {
// some codes
cb(err);
} else {
// some codes
cb();
}
});
But it returns :
{statusCode:404, data: '{"errors":[{"message":"Sorry, that page does not exist","code":34}]}'}
How can I invalidate the token plz ?
Thanks for your help.
Hey, can we add the method which returns https://twitter.com/oauth/authenticate?oauth_token=[requestToken]
instead of building the URL manually (Step 3: Getting an Access Token)?
The optional x_auth_access_type parameter allows an application request to be downgraded from write access to read only access.
https://dev.twitter.com/oauth/reference/post/oauth/request_token
I tried adding the parameter to the 'var Twitter' constructor something like this in twitter.js
this.callback = options.callback;
this.x_auth_access_type = options.x_auth_access_type;
this.oa = new oauth.OAuth("https://twitter.com/oauth/request_token", "https://twitter.com/oauth/access_token", this.consumerKey, this.consumerSecret, "1.0A", this.callback, "HMAC-SHA1", this.x_auth_access_type);
and then making a request with
readAccess = new twitterAPI({
consumerKey: key,
consumerSecret: secret,
callback: url,
x_auth_access_type: 'read'});
but I'm unsure how to encode it and due to the lack of documentation from Twitter it might even be due to not being part of the oauth npm package.
Is it possible to include the statuses/oembed end-point?
The Twitter API doesn't allow you to use it as statuses/oembed/id.json
. It requires it in the format of statuses/oembed.json?id=#
I'm using this package to get request token and access token.
but when I call for request token , I get the error below
Error getting OAuth request token : { statusCode: 401,
data: '\n\n Desktop applications only support the oauth_callback v
alue 'oob'\n /oauth/request_token\n\n' }
and here is code:
twitterAPI = require('node-twitter-api');
function setSettingForTwitter(request, response, sessionManager) {
var twitter = new twitterAPI({
consumerKey: '1YTLohgHVA9L2Mri0bM2692Rl',
consumerSecret: 'sGlYSxrs1uhS7v8qGY5fb2S8xLeNT2nACmchpONcjHO0bMfmzo',
callback: 'http://localhost.com/app/socialNetworkSetting/respondFromTwitter'
});
twitter.getRequestToken(function(error, requestToken, requestTokenSecret, results){
if (error) {
console.log("Error getting OAuth request token : " , error);
} else {
//store token and tokenSecret somewhere, you'll need them later; redirect user
}
}); }
I am using this for my latest work. But its not working for media attachments as updateWithMedia is deprecated. Can you rewrite this for uploading media and attach it to a tweet update.
Thanks.
...so that it readily appears as no longer maintained in GitHub searches
https://help.github.com/articles/archiving-a-github-repository/
I am getting {error:"media type unrecognized."}
in the body
parameter of the callback inside uploadMedia()
function. This is happening for both isBase64:true
and isBase64:false
. Please look into it.
I need to stop the current stream and start a new one.. i can start a new stream but i cant stop current running streaming
How do I set up the application for read AND write permissions? In my dashboard I already have my app set to read and write but when a user asks for permission its only asking for read.
I've tried changing my API initializing as well but it's not working.
const twitter = new twitterAPI({
consumerKey: 'y7zrtwertwretPZjguuz7P',
consumerSecret: 'DGjjetyytejwrtT',
callback: "http://localhost:8080/api/authenticate",
x_auth_access_type: 'read and write'
});
Any way to access https://dev.twitter.com/docs/api/1.1/post/statuses/update_with_media?
I've recently started uploading gifs to twitter, and I noticed that it fails randomly (like 1/10 attempts), even with small gifs. I looked into it, and Twitter recommends using the chunked upload endpoint for gifs.
https://dev.twitter.com/rest/media/uploading-media > Animated GIF recommendations
A GIF may fail during Tweet creation even if it is within the filesize limit. Adhere to the following constraints to improve success rates.
Resolution should be <= 1280x1080 (width x height)
Number of frames <= 350
Number of pixels (width * height * num_frames) <= 300 million
In order to get better support for larger GIFs, use the chunked upload endpoint with the media_category parameter. This allows the server to process the GIF file asynchronously, which is a requirement for processing larger files. Pass media_category=tweet_gif to enable async upload behavior for Tweets with an animated GIF.
What do you think about adding a method to support this behavior? It seems like we might be able to refactor Twitter.prototype.uploadVideo
into a more generic method (like Twitter.prototype.chunkedMediaUpload
) that accepts a media_type
argument.
Shortly after trying to use the statuses/lookup endpoint with this library, I got a notice from twitter ...
"This is a notice that your application, is no longer allowed to perform write operations."
But I wasn't trying to do any write operations! The only change to my app was adding the lookup call. So I looked at the code and noticed...
c4ad9f0
.
https://dev.twitter.com/docs/api/1.1/get/statuses/lookup
I had to look at the source to figure out this exists. Mostly relevant for include_email. https://dev.twitter.com/rest/reference/get/account/verify_credentials
twitter.application("rate_limit_status", {
^
TypeError: Object [object Object] has no method 'application'
Cannot get the status of my rate limits as https://dev.twitter.com/rest/reference/get/application/rate_limit_status
In twitter.js:
req.addListener('response', function (res) {
res.setEncoding('utf-8');
res.addListener('data', function (chunk) {
try {
if (chunk == "\n") {
dataCallback(null, {}, chunk, res);
} else {
dataCallback(null, JSON.parse(chunk), chunk, res);
}
} catch (e) {
dataCallback({ message: "Error while parsing Twitter-Response.", error: e }, null, chunk, res);
}
});
res.addListener('end', function() {
endCallback();
});
});
According to the Twitter API:
The body of a streaming API response consists of a series of newline-delimited messages, where "newline" is considered to be \r\n (in hex, 0x0D 0x0A) and "message" is a JSON encoded data structure or a blank line.
It seems like there are two problems with the listener:
'\r\n'
in between responses and not '\n'
. So if (chunk == "\n")
doesn't properly capture those and we get a lot of errors.JSON.parse()
a single chunk instead of the whole response as we don't wait for the '\r\n'
. twitter.statuses("update", {
status: tweet
},
If tweet starts with the charachter d or m, the api tries to direct message someone. Is there a quick and easy way to disable all of that functionality with the update function and only have it post status updates. Ie, how can I post updates that starts with d or m, that doesn't tries to send direct messages.
Most applications wouldn't want your errors displayed to their user's consoles... in my case the application we're using needs to monitor the "error" level logs in order to notify people of serious errors. Your use of "console.error" is very problematic for that.
Maybe provide some error event that the user can hook into to log the errors themselves if they really want it?
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.