From 897c6bea0ba950ecea1cb31d378cc883ef59a84f Mon Sep 17 00:00:00 2001 From: Kimura Youichi Date: Fri, 29 Apr 2016 11:50:56 +0900 Subject: [PATCH] =?utf8?q?Twitter,=20HttpTwitter=E3=82=AF=E3=83=A9?= =?utf8?q?=E3=82=B9=E3=81=AE=E4=B8=8D=E8=A6=81=E3=81=AB=E3=81=AA=E3=81=A3?= =?utf8?q?=E3=81=9F=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E3=82=92=E5=89=8A?= =?utf8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- OpenTween/Connection/HttpTwitter.cs | 117 ------------------- OpenTween/Twitter.cs | 223 ------------------------------------ 2 files changed, 340 deletions(-) diff --git a/OpenTween/Connection/HttpTwitter.cs b/OpenTween/Connection/HttpTwitter.cs index 0d4726a8..c48564ea 100644 --- a/OpenTween/Connection/HttpTwitter.cs +++ b/OpenTween/Connection/HttpTwitter.cs @@ -238,59 +238,6 @@ namespace OpenTween null); } - public HttpStatusCode ShowUserInfo(string screenName, ref string content) - { - Dictionary param = new Dictionary(); - param.Add("screen_name", screenName); - param.Add("include_entities", "true"); - param.Add("include_ext_alt_text", "true"); - return httpCon.GetContent(GetMethod, - this.CreateTwitterUri("/1.1/users/show.json"), - param, - ref content, - this.CreateRatelimitHeadersDict(), - this.CreateApiCalllback("/users/show/:id")); - } - - public HttpStatusCode CreateBlock(string screenName, ref string content) - { - Dictionary param = new Dictionary(); - param.Add("screen_name", screenName); - - return httpCon.GetContent(PostMethod, - this.CreateTwitterUri("/1.1/blocks/create.json"), - param, - ref content, - null, - null); - } - - public HttpStatusCode DestroyBlock(string screenName, ref string content) - { - Dictionary param = new Dictionary(); - param.Add("screen_name", screenName); - - return httpCon.GetContent(PostMethod, - this.CreateTwitterUri("/1.1/blocks/destroy.json"), - param, - ref content, - null, - null); - } - - public HttpStatusCode ReportSpam(string screenName, ref string content) - { - Dictionary param = new Dictionary(); - param.Add("screen_name", screenName); - - return httpCon.GetContent(PostMethod, - this.CreateTwitterUri("/1.1/users/report_spam.json"), - param, - ref content, - null, - null); - } - public HttpStatusCode ShowStatuses(long id, ref string content) { Dictionary param = new Dictionary(); @@ -304,32 +251,6 @@ namespace OpenTween this.CreateApiCalllback("/statuses/show/:id")); } - public HttpStatusCode CreateFavorites(long id, ref string content) - { - var param = new Dictionary(); - param.Add("id", id.ToString()); - - return httpCon.GetContent(PostMethod, - this.CreateTwitterUri("/1.1/favorites/create.json"), - param, - ref content, - null, - null); - } - - public HttpStatusCode DestroyFavorites(long id, ref string content) - { - var param = new Dictionary(); - param.Add("id", id.ToString()); - - return httpCon.GetContent(PostMethod, - this.CreateTwitterUri("/1.1/favorites/destroy.json"), - param, - ref content, - null, - null); - } - public HttpStatusCode HomeTimeline(int? count, long? max_id, long? since_id, ref string content) { Dictionary param = new Dictionary(); @@ -703,44 +624,6 @@ namespace OpenTween this.CreateApiCalllback("/statuses/retweeters/ids")); } - public HttpStatusCode UpdateProfile(string name, string url, string location, string description, ref string content) - { - Dictionary param = new Dictionary(); - - param.Add("name", name); - param.Add("url", url); - param.Add("location", location); - - // name, location, description に含まれる < > " の文字はTwitter側で除去されるが、 - // twitter.com の挙動では description でのみ < 等の文字参照を使って表示することができる - var escapedDescription = description.Replace("<", "<").Replace(">", ">").Replace("\"", """); - param.Add("description", escapedDescription); - - param.Add("include_entities", "true"); - param.Add("include_ext_alt_text", "true"); - - return httpCon.GetContent(PostMethod, - this.CreateTwitterUri("/1.1/account/update_profile.json"), - param, - ref content, - null, - null); - } - - public HttpStatusCode UpdateProfileImage(FileInfo imageFile, ref string content) - { - var binary = new List>(); - binary.Add(new KeyValuePair("image", new FileMediaItem(imageFile))); - - return httpCon.GetContent(PostMethod, - this.CreateTwitterUri("/1.1/account/update_profile_image.json"), - null, - binary, - ref content, - null, - null); - } - public HttpStatusCode GetBlockUserIds(ref string content, long? cursor) { var param = new Dictionary(); diff --git a/OpenTween/Twitter.cs b/OpenTween/Twitter.cs index ca19c521..55a2fd7d 100644 --- a/OpenTween/Twitter.cs +++ b/OpenTween/Twitter.cs @@ -728,93 +728,6 @@ namespace OpenTween TabInformations.GetInstance().AddPost(post); } - public void PostCreateBlock(string screenName) - { - this.CheckAccountState(); - - HttpStatusCode res; - var content = ""; - try - { - res = twCon.CreateBlock(screenName, ref content); - } - catch(Exception ex) - { - throw new WebApiException("Err:" + ex.Message + "(" + MethodBase.GetCurrentMethod().Name + ")", ex); - } - - this.CheckStatusCode(res, content); - } - - public void PostDestroyBlock(string screenName) - { - this.CheckAccountState(); - - HttpStatusCode res; - var content = ""; - try - { - res = twCon.DestroyBlock(screenName, ref content); - } - catch(Exception ex) - { - throw new WebApiException("Err:" + ex.Message + "(" + MethodBase.GetCurrentMethod().Name + ")", ex); - } - - this.CheckStatusCode(res, content); - } - - public void PostReportSpam(string screenName) - { - this.CheckAccountState(); - - HttpStatusCode res; - var content = ""; - try - { - res = twCon.ReportSpam(screenName, ref content); - } - catch(Exception ex) - { - throw new WebApiException("Err:" + ex.Message + "(" + MethodBase.GetCurrentMethod().Name + ")", ex); - } - - this.CheckStatusCode(res, content); - } - - public TwitterUser GetUserInfo(string screenName) - { - this.CheckAccountState(); - - HttpStatusCode res; - var content = ""; - try - { - res = twCon.ShowUserInfo(screenName, ref content); - } - catch(Exception ex) - { - throw new WebApiException("Err:" + ex.Message + "(" + MethodBase.GetCurrentMethod().Name + ")", ex); - } - - this.CheckStatusCode(res, content); - - try - { - return TwitterUser.ParseJson(content); - } - catch (SerializationException ex) - { - MyCommon.TraceOut(ex.Message + Environment.NewLine + content); - throw new WebApiException("Err:Json Parse Error(DataContractJsonSerializer)", content, ex); - } - catch (Exception ex) - { - MyCommon.TraceOut(ex, MethodBase.GetCurrentMethod().Name + " " + content); - throw new WebApiException("Err:Invalid Json!", content, ex); - } - } - public int GetStatus_Retweeted_Count(long StatusId) { this.CheckAccountState(); @@ -849,142 +762,6 @@ namespace OpenTween } } - public void PostFavAdd(long id) - { - this.CheckAccountState(); - - //if (this.favQueue == null) this.favQueue = new FavoriteQueue(this) - - //if (this.favQueue.Contains(id)) this.favQueue.Remove(id) - - HttpStatusCode res; - var content = ""; - try - { - res = twCon.CreateFavorites(id, ref content); - } - catch(Exception ex) - { - //this.favQueue.Add(id) - //return "Err:->FavoriteQueue:" + ex.Message + "(" + MethodBase.GetCurrentMethod().Name + ")"; - throw new WebApiException("Err:" + ex.Message + "(" + MethodBase.GetCurrentMethod().Name + ")", ex); - } - - this.CheckStatusCode(res, content); - - if (!RestrictFavCheck) - return; - - //http://twitter.com/statuses/show/id.xml APIを発行して本文を取得 - - try - { - res = twCon.ShowStatuses(id, ref content); - } - catch(Exception ex) - { - throw new WebApiException("Err:" + ex.Message, ex); - } - - this.CheckStatusCode(res, content); - - TwitterStatus status; - try - { - status = TwitterStatus.ParseJson(content); - } - catch (SerializationException ex) - { - MyCommon.TraceOut(ex.Message + Environment.NewLine + content); - throw new WebApiException("Err:Json Parse Error(DataContractJsonSerializer)", content, ex); - } - catch (Exception ex) - { - MyCommon.TraceOut(ex, MethodBase.GetCurrentMethod().Name + " " + content); - throw new WebApiException("Err:Invalid Json!", content, ex); - } - if (status.Favorited != true) - throw new WebApiException("NG(Restricted?)"); - } - - public void PostFavRemove(long id) - { - this.CheckAccountState(); - - //if (this.favQueue == null) this.favQueue = new FavoriteQueue(this) - - //if (this.favQueue.Contains(id)) - // this.favQueue.Remove(id) - // return ""; - //} - - HttpStatusCode res; - var content = ""; - try - { - res = twCon.DestroyFavorites(id, ref content); - } - catch(Exception ex) - { - throw new WebApiException("Err:" + ex.Message, ex); - } - - this.CheckStatusCode(res, content); - } - - public TwitterUser PostUpdateProfile(string name, string url, string location, string description) - { - this.CheckAccountState(); - - HttpStatusCode res; - var content = ""; - try - { - res = twCon.UpdateProfile(name, url, location, description, ref content); - } - catch(Exception ex) - { - throw new WebApiException("Err:" + ex.Message, content, ex); - } - - this.CheckStatusCode(res, content); - - try - { - return TwitterUser.ParseJson(content); - } - catch (SerializationException e) - { - var ex = new WebApiException("Err:Json Parse Error(DataContractJsonSerializer)", content, e); - MyCommon.TraceOut(ex); - throw ex; - } - catch (Exception e) - { - var ex = new WebApiException("Err:Invalid Json!", content, e); - MyCommon.TraceOut(ex); - throw ex; - } - } - - public void PostUpdateProfileImage(string filename) - { - this.CheckAccountState(); - - HttpStatusCode res; - var content = ""; - try - { - res = twCon.UpdateProfileImage(new FileInfo(filename), ref content); - } - catch(Exception ex) - { - throw new WebApiException("Err:" + ex.Message + "(" + MethodBase.GetCurrentMethod().Name + ")", ex); - } - - this.CheckStatusCode(res, content); - } - public string Username { get -- 2.11.0