diff --git a/functions/utils/twitter.js b/functions/utils/twitter.js index 9f5f97c..534d605 100644 --- a/functions/utils/twitter.js +++ b/functions/utils/twitter.js @@ -1,18 +1,15 @@ require("dotenv").config() -const Twitter = require("twitter") +const {TwitterApi} = require("twitter-api-v2") -const twitter = new Twitter({ - consumer_key: process.env.TWITTER_CONSUMER_KEY, - consumer_secret: process.env.TWITTER_CONSUMER_SECRET, - access_token_key: process.env.TWITTER_ACCESS_TOKEN_KEY, - access_token_secret: process.env.TWITTER_ACCESS_TOKEN_SECRET, +const twitter = new TwitterApi({ + appKey: process.env.TWITTER_CONSUMER_KEY, + appSecret: process.env.TWITTER_CONSUMER_SECRET, + accessToken: process.env.TWITTER_ACCESS_TOKEN_KEY, + accessSecret: process.env.TWITTER_ACCESS_TOKEN_SECRET, }) const tweet = async content => { - const response = await twitter.post("statuses/update", { - status: content, - }) - + const response = await twitter.readWrite.v2.tweet(content) return response } diff --git a/package-lock.json b/package-lock.json index 6171d80..a1c35e7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -48,7 +48,8 @@ "slugify": "^1.6.0", "spotify-web-api-node": "^5.0.0", "styled-components": "^5.3.1", - "twitter": "^1.7.1" + "twitter": "^1.7.1", + "twitter-api-v2": "^1.15.1" }, "devDependencies": { "@bradgarropy/eslint-config": "^1.1.0", @@ -30301,6 +30302,11 @@ "request": "^2.72.0" } }, + "node_modules/twitter-api-v2": { + "version": "1.15.1", + "resolved": "https://registry.npmjs.org/twitter-api-v2/-/twitter-api-v2-1.15.1.tgz", + "integrity": "sha512-KNxoJL+sldWMI3AooPGcNkbP8awQai93d9xxsTurVPuUo/qnOUR3iO0XZTGC5sezdejHHqNyTwBAgGGw948MDg==" + }, "node_modules/twitter/node_modules/deep-extend": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.5.1.tgz", @@ -54736,6 +54742,11 @@ } } }, + "twitter-api-v2": { + "version": "1.15.1", + "resolved": "https://registry.npmjs.org/twitter-api-v2/-/twitter-api-v2-1.15.1.tgz", + "integrity": "sha512-KNxoJL+sldWMI3AooPGcNkbP8awQai93d9xxsTurVPuUo/qnOUR3iO0XZTGC5sezdejHHqNyTwBAgGGw948MDg==" + }, "type": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", diff --git a/package.json b/package.json index 7875bd6..fb2e8be 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,8 @@ "slugify": "^1.6.0", "spotify-web-api-node": "^5.0.0", "styled-components": "^5.3.1", - "twitter": "^1.7.1" + "twitter": "^1.7.1", + "twitter-api-v2": "^1.15.1" }, "devDependencies": { "@bradgarropy/eslint-config": "^1.1.0",