From 29f64d216557aed039a584c9ae63bd2da53dbf18 Mon Sep 17 00:00:00 2001 From: ANIKITI Date: Thu, 13 Jun 2013 11:32:47 +0900 Subject: [PATCH] =?utf8?q?=E7=94=BB=E5=83=8F=E3=82=A2=E3=83=83=E3=83=97?= =?utf8?q?=E3=83=AD=E3=83=BC=E3=83=89=E5=AF=BE=E5=BF=9C=E3=82=B5=E3=83=BC?= =?utf8?q?=E3=83=93=E3=82=B9=E3=81=8B=E3=82=89=20Lockerz=20=E3=82=92?= =?utf8?q?=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit API が結構前に廃止されていたため (サムネイルも?) --- OpenTween/Connection/Plixi.cs | 187 -------------------------------------- OpenTween/OpenTween.csproj | 1 - OpenTween/Resources/ChangeLog.txt | 1 + OpenTween/Tween.cs | 2 - 4 files changed, 1 insertion(+), 190 deletions(-) delete mode 100644 OpenTween/Connection/Plixi.cs diff --git a/OpenTween/Connection/Plixi.cs b/OpenTween/Connection/Plixi.cs deleted file mode 100644 index c122fc56..00000000 --- a/OpenTween/Connection/Plixi.cs +++ /dev/null @@ -1,187 +0,0 @@ -// OpenTween - Client of Twitter -// Copyright (c) 2007-2011 kiri_feather (@kiri_feather) -// (c) 2008-2011 Moz (@syo68k) -// (c) 2008-2011 takeshik (@takeshik) -// (c) 2010-2011 anis774 (@anis774) -// (c) 2010-2011 fantasticswallow (@f_swallow) -// (c) 2011 spinor (@tplantd) -// All rights reserved. -// -// This file is part of OpenTween. -// -// This program is free software; you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the Free -// Software Foundation; either version 3 of the License, or (at your option) -// any later version. -// -// This program is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program. If not, see , or write to -// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, -// Boston, MA 02110-1301, USA. - -using HttpConnectionOAuthEcho = OpenTween.HttpConnectionOAuthEcho; -using IMultimediaShareService = OpenTween.IMultimediaShareService; -using Twitter = OpenTween.Twitter; -using FileInfo = System.IO.FileInfo; -using NotSupportedException = System.NotSupportedException; -using HttpStatusCode = System.Net.HttpStatusCode; -using Exception = System.Exception; -using XmlDocument = System.Xml.XmlDocument; -using XmlException = System.Xml.XmlException; -using ArgumentException = System.ArgumentException; -using System.Collections.Generic; // for Dictionary, List, KeyValuePair -using Uri = System.Uri; -using Array = System.Array; -using UploadFileType = OpenTween.MyCommon.UploadFileType; - -namespace OpenTween -{ - public class Plixi : HttpConnectionOAuthEcho, IMultimediaShareService - { - private string[] pictureExt = new string[] { ".jpg", ".jpeg", ".gif", ".png" }; - - private const long MaxFileSize = 5 * 1024 * 1024; - - private Twitter tw; - - public string Upload( ref string filePath, ref string message, long reply_to ) - { - if ( string.IsNullOrEmpty( filePath ) ) - return "Err:File isn't specified."; - if ( string.IsNullOrEmpty( message ) ) - message = ""; - FileInfo mediaFile; - try - { - mediaFile = new FileInfo( filePath ); - } - catch ( NotSupportedException ex ) - { - return "Err:" + ex.Message; - } - if ( mediaFile == null || !mediaFile.Exists ) - return "Err:File isn't exists."; - - string content = ""; - HttpStatusCode ret; - // Plixiへの投稿 - try - { - ret = this.UploadFile( mediaFile, message, ref content ); - } - catch ( Exception ex ) - { - return "Err:" + ex.Message; - } - string url = ""; - if ( ret == HttpStatusCode.Created ) - { - XmlDocument xd = new XmlDocument(); - try - { - xd.LoadXml( content ); - // MediaUrlの取得 - url = xd.ChildNodes.Item( 0 ).ChildNodes[ 2 ].InnerText; - } - catch ( XmlException ex ) - { - return "Err:" + ex.Message; - } - catch ( Exception ex ) - { - return "Err:" + ex.Message; - } - } - else - { - return "Err:" + ret.ToString(); - } - // アップロードまでは成功 - filePath = ""; - if ( string.IsNullOrEmpty( url ) ) - url = ""; - if ( string.IsNullOrEmpty( message ) ) - message = ""; - // Twitterへの投稿 - // 投稿メッセージの再構成 - if ( message.Length + AppendSettingDialog.Instance.TwitterConfiguration.CharactersReservedPerMedia + 1 > 140 ) - message = message.Substring( 0, 140 - AppendSettingDialog.Instance.TwitterConfiguration.CharactersReservedPerMedia - 1 ) + " " + url; - else - message += " " + url; - return tw.PostStatus( message, reply_to ); - } - - private HttpStatusCode UploadFile( FileInfo mediaFile, string message, ref string content ) - { - // Message必須 - if ( string.IsNullOrEmpty( message ) ) - message = ""; - // Check filetype and size(Max 5MB) - if ( !this.CheckValidExtension( mediaFile.Extension ) ) - throw new ArgumentException( "Service don't support this filetype." ); - if ( !this.CheckValidFilesize( mediaFile.Extension, mediaFile.Length ) ) - throw new ArgumentException( "File is too large." ); - - Dictionary< string, string > param = new Dictionary< string, string >(); - param.Add( "api_key", ApplicationSettings.LockerzApiKey ); - param.Add( "message", message ); - param.Add( "isoauth", "true" ); - List< KeyValuePair< string, FileInfo > > binary = new List< KeyValuePair< string, FileInfo > >(); - binary.Add( new KeyValuePair< string, FileInfo >( "media", mediaFile ) ); - this.InstanceTimeout = 60000; // タイムアウト60秒 - - return base.GetContent( HttpConnection.PostMethod, new Uri( "http://api.plixi.com/api/upload.aspx" ), param, binary, ref content, null, null ); - } - - public bool CheckValidExtension( string ext ) - { - if ( Array.IndexOf( pictureExt, ext.ToLower() ) > -1 ) - return true; - - return false; - } - - public string GetFileOpenDialogFilter() - { - return "Image Files(*.gif;*.jpg;*.jpeg;*.png)|*.gif;*.jpg;*.jpeg;*.png"; - } - - public UploadFileType GetFileType( string ext ) - { - if ( this.CheckValidExtension( ext ) ) - return UploadFileType.Picture; - - return UploadFileType.Invalid; - } - - public bool IsSupportedFileType( UploadFileType type ) - { - return type.Equals( UploadFileType.Picture ); - } - - public bool CheckValidFilesize( string ext, long fileSize ) - { - if ( this.CheckValidExtension( ext ) ) - return fileSize <= Plixi.MaxFileSize; - - return false; - } - - public bool Configuration( string key, object value ) - { - return true; - } - - public Plixi( Twitter twitter ) - : base( new Uri( "http://api.twitter.com/" ), new Uri( "https://api.twitter.com/1/account/verify_credentials.json" ) ) - { - this.tw = twitter; - base.Initialize( ApplicationSettings.TwitterConsumerKey, ApplicationSettings.TwitterConsumerSecret, tw.AccessToken, tw.AccessTokenSecret, "", "" ); - } - } -} diff --git a/OpenTween/OpenTween.csproj b/OpenTween/OpenTween.csproj index 536173d3..a7959d88 100644 --- a/OpenTween/OpenTween.csproj +++ b/OpenTween/OpenTween.csproj @@ -121,7 +121,6 @@ ListManage.cs - diff --git a/OpenTween/Resources/ChangeLog.txt b/OpenTween/Resources/ChangeLog.txt index 608a4ff9..8fbeddcc 100644 --- a/OpenTween/Resources/ChangeLog.txt +++ b/OpenTween/Resources/ChangeLog.txt @@ -1,6 +1,7 @@ 更新履歴 ==== Ver 1.1.2-beta1(2013/xx/xx) + * CHG: 画像アップロード対応サービスから Lockerz を削除 (API廃止のため) * FIX: Twitpic, yfrog, img.ly に画像をアップロードすることができない問題を修正 ==== Ver 1.1.1(2013/06/11) diff --git a/OpenTween/Tween.cs b/OpenTween/Tween.cs index 9a500664..af3dc517 100644 --- a/OpenTween/Tween.cs +++ b/OpenTween/Tween.cs @@ -1294,7 +1294,6 @@ namespace OpenTween {"TwitPic", new TwitPic(tw)}, {"img.ly", new imgly(tw)}, {"yfrog", new yfrog(tw)}, - {"lockerz", new Plixi(tw)}, {"Twitter", new TwitterPhoto(tw)} }; } @@ -12470,7 +12469,6 @@ namespace OpenTween ImageServiceCombo.Items.Add("TwitPic"); ImageServiceCombo.Items.Add("img.ly"); ImageServiceCombo.Items.Add("yfrog"); - ImageServiceCombo.Items.Add("lockerz"); ImageServiceCombo.Items.Add("Twitter"); if (string.IsNullOrEmpty(svc)) -- 2.11.0