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 3 years have passed since last update.

Windowsにtwurl CLIを入れて使う方法

Posted at

Windowsにtwurl CLIを入れて使う方法

Rubyを使ったことがないので戸惑った手順。備忘録。

必要なモジュールインストール

rubygemをインストール

ツイッターAPIをコマンド操作するtwurlをインストールするために、rubygemというパッケージ管理ツール?が必要。

Windowsでrubyをはじめよう
以下を参考にしてインストール。

twurlをインストール

Rubyのbinフォルダーに移動して以下のコマンド。

gem install twurl

C:\>cd Ruby27-x64

C:\Ruby27-x64>cd bin

C:\Ruby27-x64\bin>gem install twurl
Fetching twurl-0.9.6.gem
Fetching oauth-0.5.4.gem
Successfully installed oauth-0.5.4
Successfully installed twurl-0.9.6
Parsing documentation for oauth-0.5.4
Installing ri documentation for oauth-0.5.4
Parsing documentation for twurl-0.9.6
Installing ri documentation for twurl-0.9.6
Done installing documentation for oauth, twurl after 8 seconds
2 gems installed

パスを通しておく

twurlへのパスを通しておく。

システムのプロパティを開く

「システムの詳細設定の表示」で出てきます。
image.png

image.png

詳細設定タブの環境変数ボタン
image.png

ユーザー環境変数のPathを選んで編集ボタン
image.png

新規ボタンをクリックして、C:\Ruby27-x64\bin\twurlを入力。

image.png

twurlを有効化する

そのままではローカルPCでtwurl CLを使えない。認証作業をする。

コンシューマーキーとコンシューマーシークレットキーをお手元に

https://developer.twitter.com/en/portal/dashboard より。
image.png

認証作業

  • まずコマンドを打つ。
twurl authorize --consumer-key XxXx7xxxxxxx777xxxx0XX --consumer-secret x28pXxxXXXXXXXXxx3XxXx4xX5XX8XxXxXXx2xxxXX5xxXXXXx
  • するとこんな風に返ってくる。
Go to https://api.twitter.com/oauth/authorize?oauth_consumer_key=XtTv7tRcusH8wPzbzmS3700HU&oauth_nonce=viaOtXRYJJct47yeYc2K9Autjnq34LY13pRQzMUZIw&oauth_signature=LY%2345Xxxxxxxx97Xx8Xxxxxxx7777xxxXxX5c%253D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1604380486&oauth_token=I60asQXXXXXX-xXXXXXxXxXXxXx&oauth_version=1.0 and paste in the supplied PIN
  • https://api.twitter.com/oauth.....&oauth_version=1.0のURL文字列をコピーしてブラウズ画面を開く(コマンド画面は閉じないでそのままで)。

  • 画面を開いたら「連携アプレイを認証」をクリック。
    image.png

  • 7桁の数字が表示されている画面に遷移する。それをコピーする。
    image.png

  • コンソールに戻ってその数字をペースト。
    image.png

  • エンターすればおわり。
    image.png

jqをインストール

twurlを使う際はほとんど必須のツールなのでインストールしておく。

  1. https://stedolan.github.io/jq/
    からjq-win64.exeファイルをダウンロード。

  2. jq-win64.exeファイルを任意のフォルダにコピペ(例:C:¥temp)

  3. 先のやり方でパスを通しておく。


以上。

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?