From ca076da7a7122155265b01a3959ee2be5c5b653e Mon Sep 17 00:00:00 2001 From: hoseacodes Date: Mon, 3 Jun 2024 22:17:23 -0500 Subject: [PATCH] fix(*): update create post with twitter be --- controllers/article.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/controllers/article.js b/controllers/article.js index 00379e0..57172c7 100755 --- a/controllers/article.js +++ b/controllers/article.js @@ -141,6 +141,8 @@ async function createArticle(req, res) { medium, linkedin, linkedinContent, + tweet, + tweetConent, }); try { @@ -188,6 +190,26 @@ async function createArticle(req, res) { }); } } + if (tweet) { + try { + const response = await axios.get("https://api.twitter.com/2/tweets", { + headers: { + Authorization: `Bearer ${process.env.TWITTER_BEARER_TOKEN}`, + }, + body: { + tweet: tweetConent, + }, + }); + console.log(response); + logger.info("Published to Twitter/X"); + } catch (error) { + logger.error(error); + return res.status(error.response.status).json({ + code: error.response.statusText, + msg: error.response.data, + }); + } + } if (medium) { try {