node-red / node-red-nodes

Extra nodes for Node-RED
Other
986 stars 591 forks source link

Twitter v2.0 API not supported (returns 403) #899

Open joepavitt opened 2 years ago

joepavitt commented 2 years ago

Which node are you reporting an issue on?

Twitter

What are the steps to reproduce?

  1. Create a new instance of Node-RED
  2. Add the Twitter node
  3. Add an App/Project through the Twitter Developer Portal

What happens?

This is because Twitter have restricted access for "Essential" developer accounts (the default account provided when signing up for a Twitter developer account) to using the v2 API only. In order to use the v1.1 API, developers must have an "Elevated" account.

What do you expect to happen?

joepavitt commented 2 years ago

There is an updated Twitter NodeJS SDK: https://www.npmjs.com/package/twitter-api-v2

@Steve-Mcl and I have tested that this works in Node-RED by installing it as an npm package and used the following example, to listen for any tweet mentioning 'Boris Johnson' in a function node:

const { TwitterApi, ETwitterStreamEvent } = twitterApiV2;

// Instanciate with desired auth type (here's Bearer v2 auth)
const twitterClient = new TwitterApi("<Bearer_Token>");

// Tell typescript it's a readonly app
const roClient = twitterClient.readOnly;

const addedRules = await roClient.v2.updateStreamRules({
    add: [
        { value: 'Boris Johnson' },
    ],
});

// const stream = roClient.v2.sampleStream({ autoConnect: true });
const stream = await roClient.v2.searchStream();

stream.on(ETwitterStreamEvent.Connected, function () {
    node.send({
        payload: "Connected"
    });
});
stream.on(ETwitterStreamEvent.ConnectError, function() {
    node.send({
        payload: "Conect Error"
    });
});
stream.on(ETwitterStreamEvent.ConnectionError, function () {
    node.send({
        payload: "Conection Error"
    });
});
stream.on(ETwitterStreamEvent.Error, function () {
    node.send({
        payload: "Error"
    });
});
stream.on(ETwitterStreamEvent.Data, function () {
    node.send({
        payload: [...arguments]
    });
});
boomvalt commented 2 years ago

This problem also happens even with elevated status. Twitter Out works fine, but Twitter In still gets the 403 on public searches. Tweets from followed accounts works as expected..

shahramdj commented 1 year ago

I have developed a node-red-twitter-node that gets the public searches. You can find the code here: https://github.com/shahramdj/nodered_twitter_api I also made a youtube video that shows how you can use the new node: https://www.youtube.com/watch?v=HYn3sIDcIv4&t=78s

hardillb commented 1 year ago

@shahramdj rather than adding another node to the catalogue could we persuade you to raise a pull request to fix the existing node. This way there is just one that works and people don't have to pick from multiple options and it's the one from the community that people are likely to already have installed. Thanks

shahramdj commented 1 year ago

@hardillb sure, I will send a pull request to fix the existing node.

akashtalole commented 1 year ago

Existing twitter node must be migrated from twitter-ng to twitter-api-v2(https://www.npmjs.com/package/twitter-api-v2)

dceejay commented 1 year ago

... or wait a couple of months and see what happens :-)

gemini86 commented 1 year ago

... or wait a couple of months and see what happens :-)

Are we to take this to mean the devs are not supporting this node anymore?

knolleary commented 1 year ago

Hi @gemini86

I think the comment from @dceejay was more related to the ongoing turmoil with Twitter the company and doubts over whether the company was going to have anyone left to keep it running.

More generally, there are dozens of nodes in this repository. Ideally we'd have the resources available to fix everything and implement everything - but unfortunately we don't. The degree to which any particular node gets maintained depends a lot on how widely used it is, how much community interest there is in it and whether people want to contribute to the project to help maintain them.

gemini86 commented 1 year ago

I'm aware, which is why I asked without getting into the politics of it. I guess we wait?

dceejay commented 1 year ago

... or help @shahramdj fix/rewrite it :-)

ohrenweide commented 1 year ago

Announcing the deprecation of v1.1 statuses/filter endpoint

I guess that means the node will stop working on 9 March 2023?

ArfyFR commented 1 year ago

See https://github.com/node-red/node-red-nodes/issues/1000 I am unable to tweet from Node-red

ohrenweide commented 1 year ago

Thank you [ArfyFR] for pointing this out. For me personally, however, the abolition of free unlimited API access has settled the matter. I will not pay money for the opportunity to add value to the platform through useful bots.

ArfyFR commented 1 year ago

Thank you [ArfyFR] for pointing this out. For me personally, however, the abolition of free unlimited API access has settled the matter. I will not pay money for the opportunity to add value to the platform through useful bots.

If I understand right: Unlimited: yep no more, but Tweet caps - Post 1,500 (I suppose per month) v1.1 is for media only now V2 we should still able to send tweets

But in node-red code both try to add media and text with V1.1 => fail

ohrenweide commented 1 year ago

Unlimited: yep no more, but Tweet caps - Post 1,500 (I suppose per month)

I have been running #NowPlaying bots for BBC Radio 1/ 2/3 and BBC6Music. The limit of 1500 tweets per month is already exceeded after a few days in this case 🤷

8666 commented 1 year ago

I post less then few tweets per day and I find this plugin very useful. Is anyone working on this?

joepavitt commented 1 year ago

I post less then few tweets per day and I find this plugin very useful. Is anyone working on this?

no immediate plan that I'm aware of, with the Twitter API restrictions added, I think this dropped in priority as I understood that you needed to pay for API access now?

8666 commented 1 year ago

Posting is free (with limits) but some endpoints are not available for free anymore

jbwiden commented 10 months ago

Anybody working on a fix? Would be nice to be able to use the node to send tweets.

@shahramdj any luck with the pull request?

joepavitt commented 10 months ago

Nobody seems to have grabbed this yet unfortunately @jbwiden

shahramdj commented 10 months ago

The twitter API has changed a lot, it is not free anymore and even my fix for API version 2 does not work now.

jbwiden commented 10 months ago

My understanding is that there is still capability at the free tier but is more limited than in the past.

Free: Free, instant access to the X API. Includes 1,500 Posts /month and a single App environment. 1 App, 1 Project.

https://developer.twitter.com/en/support/twitter-api/v2

shahramdj commented 10 months ago

I had a look again and even the basic API V2 example code does not work, I get 403 error when I try to call the rules URL. I tried to find new examples, code snippets, etc. but most of the links are broken. I am not sure, maybe the free version is not their priority and they are too busy with fixing the enterprise version. Unfortunately, there is no chance at this point to fix this. If you can find any working Nodejs code that gets the twitter stream, I will be more than happy to take it and fix the node-red node twitter based on that.

jbwiden commented 8 months ago

Thanks for looking into it, sorry to hear it is seemingly a non operational API now

lzilioli commented 3 months ago

It seems like this package works with Bearer tokens: https://www.npmjs.com/package/twitter-api-v2