Skip to content

Commit

Permalink
fix(*): update create post with twitter be
Browse files Browse the repository at this point in the history
  • Loading branch information
HoseaCodes committed Jun 4, 2024
1 parent ff83b5f commit ca076da
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions controllers/article.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ async function createArticle(req, res) {
medium,
linkedin,
linkedinContent,
tweet,
tweetConent,
});

try {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit ca076da

Please sign in to comment.