Getting error while trying to use twitter 1.1 search

207 Views Asked by At

I'm trying to get tweets using twitter's standard search API, this was working fine three weeks ago and now I'm using twitter-api-client 1.3.7 and getting this:

{
   "statusCode": 403,
   "data": "{\"errors\":[{\"message\":\"You currently have access to a subset of Twitter API v2 endpoints and limited v1.1 endpoints (e.g. media post, oauth) only. If you need access to this endpoint, you may need a different access level. You can learn more here: https://developer.twitter.com/en/portal/product\",\"code\":453}]}\n"
}

this is my piece of code from my twitter controller:

Controller('Twitter')
@ApiTags('Twitter')
export class TwitterController {
  private twitterClient: TwitterClient;

  constructor(private readonly twitterService: TwitterService) {
    this.twitterClient = new TwitterClient({
      apiKey: process.env.API_KEY_TWITTER,
      apiSecret: process.env.API_KEY_SECRET_TWITTER,
      accessToken: process.env.ACESSO_TOKEN_TWITTER,
      accessTokenSecret: process.env.ACESSO_TOKEN_SECRET_TWITTER,
    });
  }

  @Get('/tweets/:tweet')
  @ApiOperation({
    summary:
      'Json',
  })
  async getTwitter(@Param('tweet') param_t: string) {
    try {
      const data = await this.twitterClient.tweets.search({
        q: '#' + param_t + '-filter:retweets',
        lang: 'en',
        count: 100,
      });

First, I was getting an authentication error and found out that my API key, bearer, and secret had disappeared from my developer account. After retrieving them again, I'm receiving this error.

0

There are 0 best solutions below