Skip to content

Commit

Permalink
Update twitter.ts
Browse files Browse the repository at this point in the history
ツイートするときにクライアント作成
  • Loading branch information
ninja03 committed Mar 9, 2024
1 parent 14797e2 commit 0cc22bf
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions twitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ import { TwitterApi } from "npm:twitter-api-v2";

// https://qiita.com/RuruCun/items/28a893cb52627b1591cc

const twitterClient = new TwitterApi({
appKey: Deno.env.get("TWITTER_APP_KEY")!,
appSecret: Deno.env.get("TWITTER_APP_SECRET")!,
accessToken: Deno.env.get("TWITTER_ACCESS_TOKEN")!,
accessSecret: Deno.env.get("TWITTER_ACCESS_SECRET")!,
});

export async function postToTwitter(message: string) {
const twitterClient = new TwitterApi({
appKey: Deno.env.get("TWITTER_APP_KEY")!,
appSecret: Deno.env.get("TWITTER_APP_SECRET")!,
accessToken: Deno.env.get("TWITTER_ACCESS_TOKEN")!,
accessSecret: Deno.env.get("TWITTER_ACCESS_SECRET")!,
});
await twitterClient.v2.tweet(message);
}

0 comments on commit 0cc22bf

Please sign in to comment.