super-ienien / twitter-webhooks

Easy to use expressJs middleware for twitter webhooks api
MIT License
20 stars 3 forks source link

403 Forbidden when using example #25

Open DanielBUBU opened 4 months ago

DanielBUBU commented 4 months ago

I want to grab posts, processing, and send it to discord when there's a new post. Access token has Read, Write, and Direct Messages permissions for sure. Here's my code

const express = require('express');
const bodyParser = require('body-parser');
const twitterWebhooks = require('twitter-webhooks');

const app = express();
app.use(bodyParser.json());
const userActivityWebhook = twitterWebhooks.userActivity({
    serverUrl: 'https://discord.com/api/webhooks/112885559..../GLecKr.....',
    route: '/', //default : '/'
    consumerKey: ,
    consumerSecret: ,
    accessToken:,
    accessTokenSecret: ,
    environment: '', //default : 'env-beta'
    app
});

//Register your webhook url - just needed once per URL
userActivityWebhook.register();

//Subscribe for a particular user activity
userActivityWebhook.subscribe({
    userId: 'DanielBUBUACG',
    accessToken: ,
    accessTokenSecret: 
}).then(function (userActivity) {
    userActivity
        .on('tweet_create', (data) => {
            console.log(userActivity.id + ' - tweet_create')
            console.log(data);
        })
});

Here is the error

D:\PD_maid\node_modules\twitter-webhooks\lib\helpers.js:34
                        error = new Error(json.errors[0].message);
                                ^

Error: Forbidden.
    at Request._callback (D:\PD_maid\node_modules\twitter-webhooks\lib\helpers.js:34:33)
    at self.callback (D:\PD_maid\node_modules\request\request.js:185:22)
    at Request.emit (node:events:518:28)
    at Request.<anonymous> (D:\PD_maid\node_modules\request\request.js:1154:10)
    at Request.emit (node:events:518:28)
    at IncomingMessage.<anonymous> (D:\PD_maid\node_modules\request\request.js:1076:12)
    at Object.onceWrapper (node:events:632:28)
    at IncomingMessage.emit (node:events:530:35)
    at endReadableNT (node:internal/streams/readable:1696:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  code: 200,
  statusCode: 403,
  body: { errors: [ { code: 200, message: 'Forbidden.' } ] }
}

Node.js v20.12.2
bircher044 commented 1 month ago

Hello! Did you find a solution?

DanielBUBU commented 1 month ago

Hello! Did you find a solution?

Not yet. But I think the package might works like a stand alone webhook client instead of a proxy, so the serverUrl: might needs to redirect to the nodejs runtime.

bircher044 commented 1 month ago

Not yet. But I think the package might works like a stand alone webhook client instead of a proxy, so the serverUrl: might needs to redirect to the nodejs runtime.

Thanks for the answer. So do you think is it possible to get live tweets withouth having a $5k+/mo apikey?

DanielBUBU commented 1 month ago

Not yet. But I think the package might works like a stand alone webhook client instead of a proxy, so the serverUrl: might needs to redirect to the nodejs runtime.

Thanks for the answer. So do you think is it possible to get live tweets withouth having a $5k+/mo apikey?

you can see that I left blanks, which are the places that enter the keys. Key shouldn't be post publicly. It won't pass the code check if you don't fill ur own key.