iT邦幫忙

DAY 17
7

現代環境下的 Linux 裡的新工具系列 第 14

在文字命令模式裡發送twitter的工具:ttytter

Facebook、Twitter 與 Plurk:我的觀察 曾有段很經典的描述:

玩 Twitter 浪費別人的時間,玩 Plurk 浪費自己的時間,玩 Facebook 浪費所有人的時間。

看看怎麼在命令列來浪費別人的時間。

不超過140字一篇的訊息,不見得一定要切到圖形界面來使用,若在命令列模式是理想的方式。目前受歡迎的網路服務,多會有API的提供,而各大的程式語言多會有提供使用該API的套件來方便寫對應的應用程式。在命令模式要執行,可透過各大程式語言來實作,但 ttytter,只要安裝在 Linux 裡就可直接使用。

安裝及設定ttytter
安裝很簡易
# pacman -S ttyter
error: target not found: ttyter
[root@backup Build]# pacman -S ttytter
resolving dependencies...
looking for inter-conflicts...

Packages (1): ttytter-2.1.00-1

Total Download Size:    0.07 MiB
Total Installed Size:   0.27 MiB

:: Proceed with installation? [Y/n]
:: Retrieving packages ...
 ttytter-2.1.00-1-any               67.1 KiB  8.19M/s 00:00 [################################] 100%
(1/1) checking keys in keyring                              [################################] 100%
(1/1) checking package integrity                            [################################] 100%
(1/1) loading package files                                 [################################] 100%
(1/1) checking for file conflicts                           [################################] 100%
(1/1) checking available disk space                         [################################] 100%
(1/1) installing ttytter                                    [################################] 100%

觀察所安裝的檔案,其實就只有一個 /usr/bin/ttytter 檔,且是 perl script 的檔案。

先直接執行看看:

]$ ttytter
trying to find cURL ... /usr/bin/curl
-- Streaming API disabled (no -dostream) (TTYtter will use REST API only)
-- no version check performed (use /vcheck, or -vcheck to check on startup)

+----------------------------------------------------------------------------+
|| WELCOME TO TTYtter: Authorize TTYtter by signing into Twitter with OAuth ||
+----------------------------------------------------------------------------+
Looks like you're starting TTYtter for the first time, and/or creating a
keyfile. Welcome to the most user-hostile, highly obfuscated, spaghetti code
infested and obscenely obscure Twitter client that's out there. You'll love it.

TTYtter generates a keyfile that contains credentials for you, including your
access tokens. This needs to be done JUST ONCE. You can take this keyfile with
you to other systems. If you revoke TTYtter's access, you must remove the
keyfile and start again with a new token. You need to do this once per account
you use with TTYtter; only one account token can be stored per keyfile. If you
have multiple accounts, use -keyf=... to specify different keyfiles. KEEP THESE
FILES SECRET.

** This wizard will overwrite /home/singernew/.ttytterkey
Press RETURN/ENTER to continue or CTRL-C NOW! to abort.

然後enter照著之後的說明來操作就可以自動幫忙設定好。

Request from http://api.twitter.com/oauth/request_token ... SUCCEEDED!

1. Visit, in your browser, ALL ON ONE LINE,

https://api.twitter.com/oauth/authorize?oauth_token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx  <== 把這網址貼到瀏覽器

看到的網頁內容像是這樣子,點選「授權應用程式」。

點選後所出現的號碼填在之後所要填的PIN的提示裡。

2. If you are not already signed in, fill in your username and password.

3. Verify that TTYtter is the requesting application, and that its permissions
are as you expect (read your timeline, see who you follow and follow new
people, update your profile, post tweets on your behalf and access your
direct messages). IF THIS IS NOT CORRECT, PRESS CTRL-C NOW!

4. Click Authorize app.

5. A PIN will appear. Enter it below.

Enter PIN> 5017553

Request from http://api.twitter.com/oauth/access_token ... SUCCEEDED!
Written keyfile /home/singernew/.ttytterkey

Now, restart TTYtter to use this keyfile.
(To choose between multiple keyfiles other than the default .ttytterkey,
 tell TTYtter where the key is using -keyf=... .)
$

這樣就設定完成。
然後在家目錄下就多了一個 ~/.ttytterkey 的設定檔。

執行使用
之後只要再screen或tmux開個window或pane,執行ttytter:

$ ttytter
trying to find cURL ... /usr/bin/curl
-- Streaming API disabled (no -dostream) (TTYtter will use REST API only)
-- no version check performed (use /vcheck, or -vcheck to check on startup)
(checking credentials) test-login SUCCEEDED!
-- processing credentials: logged in as singernew2

######################################################        +oo=========oo+
         TTYtter 2.1.0  (c)2012 cameron kaiser                @             @
                 all rights reserved.                         +oo=   =====oo+
       http://www.floodgap.com/software/ttytter/            a==:  ooo
                                                            .++o++. ..o**O
  freeware under the floodgap free software license.        +++   :O:::::
        http://www.floodgap.com/software/ffsl/              +**O++ #   :ooa
                                                                   #+$$AB=.
         tweet me: http://twitter.com/ttytter                      #;;ooo;;
            tell me: ckaiser@floodgap.com                          #+a;+++;O
######################################################           ,$B.*o*** O$,
#                                                                a=o$*O*O*$o=a
# when ready, hit RETURN/ENTER for a prompt.                        @$$$$$@
# type /help for commands or /quit to quit.                         @o@o@o@
# starting background monitoring process.                           @=@ @=@
#
TTYtter> -- rate limit rate failure: using 180 second fallback
-- no version check performed (use /vcheck, or -vcheck to check on startup)
-- you are logged in as singernew2

TTYtter> 從ttytter發的第一篇twitter。http://www.floodgap.com/software/ttytter/
TTYtter> a0> <singernew2> 從ttytter發的第一篇twitter。http://www.floodgap.com/software/ttytter/

TTYtter>

這樣就可在不離開shell的情況下,把自己的高言大志隨時抒發在twitter上了。


上一篇
完全無用的彩色ascii art動畫:ASCIIQuarium
下一篇
用指令查字典:dict;結果架dictd的服務
系列文
現代環境下的 Linux 裡的新工具27
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

2 則留言

0
SunAllen
iT邦研究生 1 級 ‧ 2013-10-02 09:44:37

Twitter 讚!!!沙發

0
wordsmith
iT邦高手 1 級 ‧ 2013-10-02 12:38:11
&lt;pre class="c" name="code">trying to find cURL ... /usr/bin/curl
-- no version check performed (use /vcheck, or -vcheck to check on startup)
(checking credentials) test-login SUCCEEDED!
-- processing credentials: FAILED!
is your account suspended, or wrong token?

試了一下失敗 Orz

我要留言

立即登入留言