Do You PHP はてブロ

Do You PHPはてなからはてブロに移動しました

Twitkit-1.1が動かなくなったので直してみた

Twitterクライアントとして愛用しているFirefoxアドオンのTwitkitですが、タイムラインが全く更新されていないことに気づきました。まあ、忙しくてTwitkitを見てなかったので、気づかなかっただけかも知れませんが。。。
とりあえず、LiveHTTPHeaderで見てみると、APIリクエストでHTTP 400とかHTTP 404とかがバシバシ返ってきていました。で、Twitkitのxpiをばらして、javascriptソース(chrome/content/twitkit.js)とhttp://apiwiki.twitter.com/REST+API+Documentationを比べてみると、リクエストメソッドが違っていたり、URLが変わっていたりすることが判明。
そこで、このエントリの最後のように修正し、xpiファイルのtwitkit.jsを更新。Firefoxに再度インストールしてみると、うまく動きました。修正後のxpiをDo You PHP?にUPしてありますので、奇特な方は自己責任でどうぞ。

*** chrome/content/twitkit.js.org       2009-04-09 22:19:36.000000000 +0900
--- chrome/content/twitkit.js   2009-04-09 22:19:52.000000000 +0900
***************
*** 188,194 ****
              if ( !Tweetbar.httpHeaders ) {
                  Tweetbar.httpHeaders = {
                      'X-Twitter-Client': 'TwitKit',
!                     'X-Twitter-Client-Version': '1.1',
                      'X-Twitter-Client-URL': 'http://engel.uk.to/twitkit/1.1.xml',
                  };
                  if ( Tweetbar.username && Tweetbar.password )
--- 188,194 ----
              if ( !Tweetbar.httpHeaders ) {
                  Tweetbar.httpHeaders = {
                      'X-Twitter-Client': 'TwitKit',
!                     'X-Twitter-Client-Version': '1.1-shimooka',
                      'X-Twitter-Client-URL': 'http://engel.uk.to/twitkit/1.1.xml',
                  };
                  if ( Tweetbar.username && Tweetbar.password )
***************
*** 539,544 ****
--- 539,545 ----
                  ( this.currentList == 'friends' ) ? theurl = Tweetbar.protocol + '://twitter.com/statuses/friends/' + this.username + '.json?lite=true' : theurl = Tweetbar.protocol + '://twitter.com/statuses/followers.json?lite=true';
                  var aj = new Ajax( theurl,
                                     { headers: Tweetbar.http_headers(),
+                                      method: 'get',
                                       postBody: {},
                                       onSuccess:
                                          function (raw_data) {
***************
*** 559,564 ****
--- 560,566 ----
              } else if ( this.currentList == 'replies' ) {
                  var aj = new Ajax( Tweetbar.protocol + '://twitter.com/statuses/replies.json',
                                     { headers: Tweetbar.http_headers(),
+                                      method: 'get',
                                       postBody: {},
                                       onSuccess:
                                          function (raw_data) {
***************
*** 578,583 ****
--- 580,586 ----
              } else if ( this.currentList == 'me' ) {
                  var aj = new Ajax( Tweetbar.protocol + '://twitter.com/users/show/' + this.username + '.json',
                                     { headers: Tweetbar.http_headers(),
+                                      method: 'get',
                                       postBody: {},
                                       onSuccess:
                                          function (raw_data) {
***************
*** 611,616 ****
--- 614,620 ----
              var panel = Tweetbar.currentList;
              var aj = new Ajax( Tweetbar.api_url_for(panel),
                                { headers: Tweetbar.http_headers(),
+                                 method: 'get',
                                  postBody: {},
                                  onComplete:
                                      function (raw_data) {
***************
*** 1022,1028 ****
       */
      sign_out:
          function () {
!             var aj = new Ajax( Tweetbar.protocol + '://twitter.com/account/end_session',
                                 { headers: Tweetbar.http_headers(),
                                   postBody: {},
                                   onSuccess:
--- 1026,1032 ----
       */
      sign_out:
          function () {
!             var aj = new Ajax( Tweetbar.protocol + '://twitter.com/account/end_session.json',
                                 { headers: Tweetbar.http_headers(),
                                   postBody: {},
                                   onSuccess:
***************
*** 1066,1071 ****
--- 1070,1076 ----

              var authr = new Ajax( Tweetbar.protocol + '://twitter.com/account/verify_credentials',
                                    { headers: this.http_headers(),
+                                     method: 'get',
                                      postBody: {},
                                      onComplete:
                                          function (raw_data) {

追記(2009/04/13 11:30)

Twitkit-1.2がリリースされています。このエントリの内容と同じ修正も入っているようです。