From f7b13db0ac0a2e983905bae9e2e2655c916604ce Mon Sep 17 00:00:00 2001 From: Kimura Youichi Date: Thu, 29 Mar 2012 23:26:40 +0900 Subject: [PATCH] =?utf8?q?bit.ly=20=E7=9F=AD=E7=B8=AE=E6=A9=9F=E8=83=BD?= =?utf8?q?=E5=AE=9F=E8=A3=85=E3=81=AE=E3=83=97=E3=83=A9=E3=82=A4=E3=83=90?= =?utf8?q?=E3=82=B7=E3=83=BC=E5=95=8F=E9=A1=8C=E3=81=AE=E6=9A=AB=E5=AE=9A?= =?utf8?q?=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 当面の間はAPIキーの指定を必須とし、指定されていない場合はbit.lyによって短縮されない (t.coによって短縮される) 参照: http://sourceforge.jp/projects/opentween/lists/archive/dev/2012-January/000020.html --- OpenTween/AppendSettingDialog.cs | 23 ++++++++++++++++++----- OpenTween/ShortUrl.cs | 13 ++++++++++--- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/OpenTween/AppendSettingDialog.cs b/OpenTween/AppendSettingDialog.cs index 7d26f960..a596658f 100644 --- a/OpenTween/AppendSettingDialog.cs +++ b/OpenTween/AppendSettingDialog.cs @@ -113,14 +113,27 @@ namespace OpenTween private void Save_Click(object sender, EventArgs e) { if (MyCommon.IsNetworkAvailable() && - (ComboBoxAutoShortUrlFirst.SelectedIndex == (int)MyCommon.UrlConverter.Bitly || ComboBoxAutoShortUrlFirst.SelectedIndex == (int)MyCommon.UrlConverter.Jmp) && - (!string.IsNullOrEmpty(TextBitlyId.Text) || !string.IsNullOrEmpty(TextBitlyPw.Text))) + (ComboBoxAutoShortUrlFirst.SelectedIndex == (int)MyCommon.UrlConverter.Bitly || ComboBoxAutoShortUrlFirst.SelectedIndex == (int)MyCommon.UrlConverter.Jmp)) { + // bit.ly 短縮機能実装のプライバシー問題の暫定対応 + // bit.ly 使用時はログインIDとAPIキーの指定を必須とする + // 参照: http://sourceforge.jp/projects/opentween/lists/archive/dev/2012-January/000020.html + if (string.IsNullOrEmpty(TextBitlyId.Text) || string.IsNullOrEmpty(TextBitlyPw.Text)) + { + MessageBox.Show("bit.ly のログイン名とAPIキーの指定は必須項目です。", Application.ProductName); + _ValidationError = true; + TreeViewSetting.SelectedNode = TreeViewSetting.Nodes["ConnectionNode"].Nodes["ShortUrlNode"]; // 動作タブを選択 + TreeViewSetting.Select(); + TextBitlyId.Focus(); + return; + } + if (!BitlyValidation(TextBitlyId.Text, TextBitlyPw.Text)) { MessageBox.Show(Properties.Resources.SettingSave_ClickText1); _ValidationError = true; - TreeViewSetting.SelectedNode.Name = "TweetActNode"; // 動作タブを選択 + TreeViewSetting.SelectedNode = TreeViewSetting.Nodes["ConnectionNode"].Nodes["ShortUrlNode"]; // 動作タブを選択 + TreeViewSetting.Select(); TextBitlyId.Focus(); return; } @@ -1960,8 +1973,8 @@ namespace OpenTween string content = ""; Dictionary param = new Dictionary(); - param.Add("login", "tweenapi"); - param.Add("apiKey", "R_c5ee0e30bdfff88723c4457cc331886b"); + param.Add("login", ApplicationSettings.BitlyLoginId); + param.Add("apiKey", ApplicationSettings.BitlyApiKey); param.Add("x_login", id); param.Add("x_apiKey", apikey); param.Add("format", "txt"); diff --git a/OpenTween/ShortUrl.cs b/OpenTween/ShortUrl.cs index aefaf0f5..7aafc6cd 100644 --- a/OpenTween/ShortUrl.cs +++ b/OpenTween/ShortUrl.cs @@ -330,13 +330,20 @@ namespace OpenTween content = src; break; } + if (string.IsNullOrEmpty(_bitlyId) || string.IsNullOrEmpty(_bitlyKey)) + { + // bit.ly 短縮機能実装のプライバシー問題の暫定対応 + // ログインIDとAPIキーが指定されていない場合は短縮せずにPOSTする + // 参照: http://sourceforge.jp/projects/opentween/lists/archive/dev/2012-January/000020.html + content = src; + break; + } string req = ""; req = "http://api.bitly.com/v" + BitlyApiVersion + "/shorten?"; - req += "login=" + ApplicationSettings.BitlyLoginId + - "&apiKey=" + ApplicationSettings.BitlyApiKey + + req += "login=" + _bitlyId + + "&apiKey=" + _bitlyKey + "&format=txt" + "&longUrl=" + SrcUrl; - if (!string.IsNullOrEmpty(_bitlyId) && !string.IsNullOrEmpty(_bitlyKey)) req += "&x_login=" + _bitlyId + "&x_apiKey=" + _bitlyKey; if (ConverterType == MyCommon.UrlConverter.Jmp) req += "&domain=j.mp"; if (!(new HttpVarious()).GetData(req, null, out content)) { -- 2.11.0