0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

StreamDeckっぽいものを作る_5

Posted at

python-twitterをインストールしておく。
APIキー等は各自用意したものに合わせる

import twitter

#   定数関係
from const import *

#   ツイッター操作クラス
class TwitterUtil:

    #   取得したキーとアクセストークンを設定する
    #   https://apps.twitter.com/ から Create an appで登録してプロジェクト作っていろいろなキーを取得する
    #   User authenticationとかTwitter API v2とか有効にしとく(もしかしたらなくてもいいかも) 2023/01/08現在
    auth = twitter.OAuth(consumer_key=TWITTERAPIKEY,  #   api key
                        consumer_secret=TWITTERAPIKEYSECRET,    #   API secret,
                        token=TWITTERACCESSTOKEN,   #   Access token
                        token_secret=TWITTERACCESSTOKENSECRET)    #  Access token secret 

    #   ツイート
    def post(self, dicPostParams):
        tw = twitter.Twitter(auth=self.auth)
        tw.statuses.update(status=dicPostParams[TWITTERPOST_TEXT])  #   twitterへメッセージを投稿する
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?