Skip to content

Commit

Permalink
Doesnt seem to be tweeting
Browse files Browse the repository at this point in the history
  • Loading branch information
jongan69 committed Jan 4, 2025
1 parent dc49da7 commit 435596c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
20 changes: 18 additions & 2 deletions src/pages/api/cron/route.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
import getTrends from '@utils/getTrends';
import { postTweet } from '../twitter/tweet';
// import { NextResponse } from 'next/server';
import { formatTrendsTweet } from '@utils/formatTweet';
import Twitter from 'twitter-api-v2';

export const dynamic = 'force-dynamic'; // static by default, unless reading the request

const client = new Twitter({
appKey: process.env.TWITTER_API_KEY!,
appSecret: process.env.TWITTER_API_SECRET!,
accessToken: process.env.TWITTER_ACCESS_TOKEN!,
accessSecret: process.env.TWITTER_ACCESS_TOKEN_SECRET!,
});

export async function postTweet(message: string) {
try {
await client.v2.tweet(message);
console.log('Successfully tweeted:', message);
} catch (error) {
console.error('Error posting tweet:', error);
console.log(error);
}
}

export async function GET(request: Request) {
try {
// Get trends data
Expand Down
18 changes: 0 additions & 18 deletions src/pages/api/twitter/tweet.ts

This file was deleted.

0 comments on commit 435596c

Please sign in to comment.