using System.Linq;
using System.Text;
using System.Windows.Forms;
+using OpenTween.Api;
using Xunit;
using Xunit.Extensions;
// TweetFormatterでHTMLに整形 → CreateRetweetUnofficialで復元 までの動作が正しく行えているか
var text = "#てすと @TwitterAPI \n http://t.co/KYi7vMZzRt";
- var entities = new TwitterDataModel.Entity[]
+ var entities = new TwitterEntity[]
{
- new TwitterDataModel.Hashtags
+ new TwitterEntityHashtag
{
Indices = new[] { 0, 4 },
Text = "てすと",
},
- new TwitterDataModel.UserMentions
+ new TwitterEntityMention
{
Indices = new[] { 5, 16 },
Id = 6253282L,
Name = "Twitter API",
ScreenName = "twitterapi",
},
- new TwitterDataModel.Urls
+ new TwitterEntityUrl
{
Indices = new[] { 19, 41 },
DisplayUrl = "twitter.com",
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using OpenTween.Api;
using Xunit;
using Xunit.Extensions;
var text = "http://t.co/KYi7vMZzRt";
var entities = new[]
{
- new TwitterDataModel.Urls
+ new TwitterEntityUrl
{
Indices = new[] { 0, 22 },
DisplayUrl = "twitter.com",
var text = "#OpenTween";
var entities = new[]
{
- new TwitterDataModel.Hashtags
+ new TwitterEntityHashtag
{
Indices = new[] { 0, 10 },
Text = "OpenTween",
var text = "@TwitterAPI";
var entities = new[]
{
- new TwitterDataModel.UserMentions
+ new TwitterEntityMention
{
Indices = new[] { 0, 11 },
Id = 6253282L,
var text = "http://t.co/h5dCr4ftN4";
var entities = new[]
{
- new TwitterDataModel.Media
+ new TwitterEntityMedia
{
Indices = new[] { 0, 22 },
- Sizes = new TwitterDataModel.Sizes
+ Sizes = new TwitterMediaSizes
{
- Large = new TwitterDataModel.SizeElement { Resize = "fit", h = 329, w = 1024 },
- Medium = new TwitterDataModel.SizeElement { Resize = "fit", h = 204, w = 600 },
- Small = new TwitterDataModel.SizeElement { Resize = "fit", h = 116, w = 340 },
- Thumb = new TwitterDataModel.SizeElement { Resize = "crop", h = 150, w = 150 },
+ Large = new TwitterMediaSizes.Size { Resize = "fit", Height = 329, Width = 1024 },
+ Medium = new TwitterMediaSizes.Size { Resize = "fit", Height = 204, Width = 600 },
+ Small = new TwitterMediaSizes.Size { Resize = "fit", Height = 116, Width = 340 },
+ Thumb = new TwitterMediaSizes.Size { Resize = "crop", Height = 150, Width = 150 },
},
Type = "photo",
Id = 426404550379986940L,
public void AutoLinkHtml_EntityNullTest()
{
var text = "てすとてすとー";
- TwitterDataModel.Entities entities = null;
+ TwitterEntities entities = null;
var expected = "てすとてすとー";
Assert.Equal(expected, TweetFormatter.AutoLinkHtml(text, entities));
public void AutoLinkHtml_EntityNullTest2()
{
var text = "てすとてすとー";
- TwitterDataModel.Entities entities = new TwitterDataModel.Entities
+ TwitterEntities entities = new TwitterEntities
{
Urls = null,
Hashtags = null,
public void AutoLinkHtml_EntityNullTest3()
{
var text = "てすとてすとー";
- IEnumerable<TwitterDataModel.Entity> entities = null;
+ IEnumerable<TwitterEntity> entities = null;
var expected = "てすとてすとー";
Assert.Equal(expected, TweetFormatter.AutoLinkHtml(text, entities));
public void AutoLinkHtml_EntityNullTest4()
{
var text = "てすとてすとー";
- IEnumerable<TwitterDataModel.Entity> entities = new TwitterDataModel.Entity[] { null };
+ IEnumerable<TwitterEntity> entities = new TwitterEntity[] { null };
var expected = "てすとてすとー";
Assert.Equal(expected, TweetFormatter.AutoLinkHtml(text, entities));
var text = "\"\'@twitterapi\'\"";
var entities = new[]
{
- new TwitterDataModel.UserMentions
+ new TwitterEntityMention
{
Indices = new[] { 2, 13 },
Id = 6253282L,
var text = "<b> @twitterapi </b>";
var entities = new[]
{
- new TwitterDataModel.UserMentions
+ new TwitterEntityMention
{
Indices = new[] { 10, 21 },
Id = 6253282L,
var text = "<b> @twitterapi </b>";
var entities = new[]
{
- new TwitterDataModel.UserMentions
+ new TwitterEntityMention
{
Indices = new[] { 4, 15 },
Id = 6253282L,
var text = "#ぜんぶ雪のせいだ";
var entities = new[]
{
- new TwitterDataModel.Hashtags
+ new TwitterEntityHashtag
{
Indices = new[] { 0, 9 },
Text = "ぜんぶ雪のせいだ",
var text = "🐬🐬 @irucame 🐬🐬";
var entities = new[]
{
- new TwitterDataModel.UserMentions
+ new TwitterEntityMention
{
Indices = new[] { 3, 11 },
Id = 89942943L,
var text = "🐬🐬 #🐬🐬 🐬🐬 #🐬🐬 🐬🐬";
var entities = new[]
{
- new TwitterDataModel.Hashtags
+ new TwitterEntityHashtag
{
Indices = new[] { 3, 6 },
Text = "🐬🐬",
},
- new TwitterDataModel.Hashtags
+ new TwitterEntityHashtag
{
Indices = new[] { 10, 13 },
Text = "🐬🐬",
var text = "Caf\u00e9 #test";
var entities = new[]
{
- new TwitterDataModel.Hashtags
+ new TwitterEntityHashtag
{
Indices = new[] { 5, 10 },
Text = "test",
var text = "Cafe\u0301 #test";
var entities = new[]
{
- new TwitterDataModel.Hashtags
+ new TwitterEntityHashtag
{
Indices = new[] { 6, 11 },
Text = "test",
public void AutoLinkHtml_BreakLineTest()
{
var text = "てすと\nてすと\nてすと";
- TwitterDataModel.Entities entities = null;
+ TwitterEntities entities = null;
var expected = "てすと<br>てすと<br>てすと";
Assert.Equal(expected, TweetFormatter.AutoLinkHtml(text, entities));
--- /dev/null
+// OpenTween - Client of Twitter
+// Copyright (c) 2014 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
+// 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 <http://www.gnu.org/licenses/>, or write to
+// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
+// Boston, MA 02110-1301, USA.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OpenTween.Api
+{
+ [DataContract]
+ public abstract class GeoJson
+ {
+ [DataMember(Name = "type")]
+ public string Type { get; set; }
+ }
+
+ [DataContract]
+ public class GeoJsonPoint : GeoJson
+ {
+ [DataMember(Name = "coordinates")]
+ public double[] Coordinates { get; set; }
+
+ public GeoJsonPoint()
+ {
+ this.Type = "Point";
+ }
+ }
+
+ [DataContract]
+ public class GeoJsonPolygon : GeoJson
+ {
+ [DataMember(Name = "coordinates")]
+ public double[][][] Coordinates { get; set; }
+
+ public GeoJsonPolygon()
+ {
+ this.Type = "Polygon";
+ }
+ }
+}
--- /dev/null
+// OpenTween - Client of Twitter
+// Copyright (c) 2007-2011 kiri_feather (@kiri_feather) <kiri.feather@gmail.com>
+// (c) 2008-2011 Moz (@syo68k)
+// (c) 2008-2011 takeshik (@takeshik) <http://www.takeshik.org/>
+// (c) 2010-2011 anis774 (@anis774) <http://d.hatena.ne.jp/anis774/>
+// (c) 2010-2011 fantasticswallow (@f_swallow) <http://twitter.com/f_swallow>
+// (c) 2011 Egtra (@egtra) <http://dev.activebasic.com/egtra/>
+// (c) 2013 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
+// 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 <http://www.gnu.org/licenses/>, or write to
+// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
+// Boston, MA 02110-1301, USA.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OpenTween.Api
+{
+ [DataContract]
+ public class TwitterConfiguration
+ {
+ [DataMember(Name = "characters_reserved_per_media")]
+ public int CharactersReservedPerMedia { get; set; }
+
+ [DataMember(Name = "photo_size_limit")]
+ public int PhotoSizeLimit { get; set; }
+
+ [DataMember(Name = "photo_sizes")]
+ public TwitterMediaSizes PhotoSizes { get; set; }
+
+ [DataMember(Name = "non_username_paths")]
+ public string[] NonUsernamePaths { get; set; }
+
+ [DataMember(Name = "short_url_length")]
+ public int ShortUrlLength { get; set; }
+
+ [DataMember(Name = "short_url_length_https")]
+ public int ShortUrlLengthHttps { get; set; }
+
+ [DataMember(Name = "max_media_per_upload")]
+ public int MaxMediaPerUpload { get; set; }
+
+ /// <exception cref="SerializationException"/>
+ public static TwitterConfiguration ParseJson(string json)
+ {
+ return MyCommon.CreateDataFromJson<TwitterConfiguration>(json);
+ }
+
+ /// <summary>
+ /// 設定が取得できるまでの間に代わりに使用する適当な値を返します
+ /// </summary>
+ public static TwitterConfiguration DefaultConfiguration()
+ {
+ return new TwitterConfiguration
+ {
+ CharactersReservedPerMedia = 20,
+ ShortUrlLength = 19,
+ ShortUrlLengthHttps = 20,
+ };
+ }
+ }
+}
--- /dev/null
+// OpenTween - Client of Twitter
+// Copyright (c) 2014 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
+// 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 <http://www.gnu.org/licenses/>, or write to
+// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
+// Boston, MA 02110-1301, USA.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OpenTween.Api
+{
+ // 参照: https://dev.twitter.com/docs/platform-objects/entities
+
+ [DataContract]
+ public class TwitterEntities
+ {
+ [DataMember(Name = "hashtags")]
+ public TwitterEntityHashtag[] Hashtags { get; set; }
+
+ [DataMember(Name = "media", IsRequired = false)]
+ public TwitterEntityMedia[] Media { get; set; }
+
+ [DataMember(Name = "urls")]
+ public TwitterEntityUrl[] Urls { get; set; }
+
+ [DataMember(Name = "user_mentions")]
+ public TwitterEntityMention[] UserMentions { get; set; }
+ }
+
+ [DataContract]
+ public abstract class TwitterEntity
+ {
+ [DataMember(Name = "indices")]
+ public int[] Indices { get; set; }
+ }
+
+ [DataContract]
+ public class TwitterEntityHashtag : TwitterEntity
+ {
+ [DataMember(Name = "text")]
+ public string Text { get; set; }
+ }
+
+ [DataContract]
+ public class TwitterEntityMedia : TwitterEntityUrl
+ {
+ [DataMember(Name = "id")]
+ public long Id { get; set; }
+
+ [DataMember(Name = "id_str")]
+ public string IdStr { get; set; }
+
+ [DataMember(Name = "media_url")]
+ public string MediaUrl { get; set; }
+
+ [DataMember(Name = "media_url_https")]
+ public string MediaUrlHttps { get; set; }
+
+ [DataMember(Name = "sizes")]
+ public TwitterMediaSizes Sizes { get; set; }
+
+ [DataMember(Name = "source_status_id")]
+ public long SourceStatusId { get; set; }
+
+ [DataMember(Name = "source_status_id_str")]
+ public string SourceStatusIdStr { get; set; }
+
+ [DataMember(Name = "type")]
+ public string Type { get; set; }
+ }
+
+ [DataContract]
+ public class TwitterMediaSizes
+ {
+ [DataMember(Name = "thumb")]
+ public TwitterMediaSizes.Size Thumb { get; set; }
+
+ [DataMember(Name = "large")]
+ public TwitterMediaSizes.Size Large { get; set; }
+
+ [DataMember(Name = "medium")]
+ public TwitterMediaSizes.Size Medium { get; set; }
+
+ [DataMember(Name = "small")]
+ public TwitterMediaSizes.Size Small { get; set; }
+
+ [DataContract]
+ public class Size
+ {
+ [DataMember(Name = "h")]
+ public int Height { get; set; }
+
+ [DataMember(Name = "resize")]
+ public string Resize { get; set; }
+
+ [DataMember(Name = "w")]
+ public int Width { get; set; }
+ }
+ }
+
+ [DataContract]
+ public class TwitterEntityUrl : TwitterEntity
+ {
+ [DataMember(Name = "display_url")]
+ public string DisplayUrl { get; set; }
+
+ [DataMember(Name = "expanded_url")]
+ public string ExpandedUrl { get; set; }
+
+ [DataMember(Name = "url")]
+ public string Url { get; set; }
+ }
+
+ [DataContract]
+ public class TwitterEntityMention : TwitterEntity
+ {
+ [DataMember(Name = "id")]
+ public long Id { get; set; }
+
+ [DataMember(Name = "id_str")]
+ public string IdStr { get; set; }
+
+ [DataMember(Name = "name")]
+ public string Name { get; set; }
+
+ [DataMember(Name = "screen_name")]
+ public string ScreenName { get; set; }
+ }
+}
--- /dev/null
+// OpenTween - Client of Twitter
+// Copyright (c) 2014 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
+// 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 <http://www.gnu.org/licenses/>, or write to
+// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
+// Boston, MA 02110-1301, USA.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OpenTween.Api
+{
+ // 参照: https://dev.twitter.com/docs/error-codes-responses
+
+ [DataContract]
+ public class TwitterError
+ {
+ [DataMember(Name = "errors")]
+ public TwitterErrorItem[] Errors { get; set; }
+
+ /// <exception cref="SerializationException"/>
+ public static TwitterError ParseJson(string json)
+ {
+ return MyCommon.CreateDataFromJson<TwitterError>(json);
+ }
+ }
+
+ [DataContract]
+ public class TwitterErrorItem
+ {
+ [DataMember(Name = "code")]
+ public TwitterErrorCode Code { get; set; }
+
+ [DataMember(Name = "message")]
+ public string Message { get; set; }
+
+ public override string ToString()
+ {
+ if (Enum.IsDefined(typeof(TwitterErrorCode), this.Code))
+ return this.Code.ToString();
+ else
+ return this.Message;
+ }
+ }
+
+ /// <summary>
+ /// Twitter API から返されるエラーコード
+ /// </summary>
+ public enum TwitterErrorCode : int
+ {
+ /// <summary>
+ /// 不正なリクエスト等によって認証を完了できない場合に発生する。大体クライアントのせい
+ /// </summary>
+ AuthError = 32,
+
+ /// <summary>
+ /// 指定されたリソースが存在しません。HTTP 404 と同等
+ /// </summary>
+ NotFound = 34,
+
+ /// <summary>
+ /// アカウントが凍結されています
+ /// </summary>
+ SuspendedAccount = 64,
+
+ /// <summary>
+ /// REST API v1 は星になりました
+ /// </summary>
+ APIv1Retired = 68,
+
+ /// <summary>
+ /// レートリミットに到達しました
+ /// </summary>
+ RateLimit = 88,
+
+ /// <summary>
+ /// アクセストークンが無効です。不正なトークンまたはユーザーによって失効されています
+ /// </summary>
+ InvalidToken = 89,
+
+ /// <summary>
+ /// サーバーの過負荷によって一時的にアクセスできません
+ /// </summary>
+ OverCapacity = 130,
+
+ /// <summary>
+ /// サーバーの内部エラー
+ /// </summary>
+ InternalError = 131,
+
+ /// <summary>
+ /// oauth_timestamp の時刻が無効。クライアントかサーバーの時計が大幅にずれている
+ /// </summary>
+ TimestampOutOfRange = 135,
+
+ /// <summary>
+ /// ユーザーからブロックされている (公式ドキュメントに記述無し)
+ /// </summary>
+ Blocked = 136,
+
+ /// <summary>
+ /// 既にふぁぼっているツイートをふぁぼろうとした (公式ドキュメントに記述無し)
+ /// </summary>
+ AlreadyFavorited = 139,
+
+ /// <summary>
+ /// フォローの追加が制限されています
+ /// </summary>
+ FollowLimit = 161,
+
+ /// <summary>
+ /// 投稿されたステータスが重複しています
+ /// </summary>
+ DuplicateStatus = 187,
+
+ /// <summary>
+ /// 認証が必要な API で認証データが含まれていない、または認証データが不正
+ /// </summary>
+ AuthenticationRequired = 215,
+
+ /// <summary>
+ /// 廃止されたエンドポイント
+ /// </summary>
+ RetiredEndpoint = 251,
+ }
+}
--- /dev/null
+// OpenTween - Client of Twitter
+// Copyright (c) 2014 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
+// 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 <http://www.gnu.org/licenses/>, or write to
+// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
+// Boston, MA 02110-1301, USA.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OpenTween.Api
+{
+ [DataContract]
+ public class TwitterFriendship
+ {
+ [DataMember(Name = "relationship")]
+ public TwitterFriendship.RelationshipItem Relationship { get; set; }
+
+ [DataContract]
+ public class RelationshipItem
+ {
+ [DataMember(Name = "target")]
+ public TwitterFriendship.RelationshipTarget Target { get; set; }
+
+ [DataMember(Name = "source")]
+ public TwitterFriendship.RelationshipSource Source { get; set; }
+ }
+
+ [DataContract]
+ public class RelationshipTarget
+ {
+ [DataMember(Name = "id")]
+ public long Id { get; set; }
+
+ [DataMember(Name = "id_str")]
+ public string IdStr { get; set; }
+
+ [DataMember(Name = "screen_name")]
+ public string ScreenName { get; set; }
+
+ [DataMember(Name = "following")]
+ public bool Following { get; set; }
+
+ [DataMember(Name = "followed_by")]
+ public bool FollowedBy { get; set; }
+ }
+
+ [DataContract]
+ public class RelationshipSource
+ {
+ [DataMember(Name = "id")]
+ public long Id { get; set; }
+
+ [DataMember(Name = "id_str")]
+ public string IdStr { get; set; }
+
+ [DataMember(Name = "screen_name")]
+ public string ScreenName { get; set; }
+
+ [DataMember(Name = "following")]
+ public bool Following { get; set; }
+
+ [DataMember(Name = "followed_by")]
+ public bool FollowedBy { get; set; }
+
+ [DataMember(Name = "marked_spam")]
+ public bool? MarkedSpam { get; set; }
+
+ [DataMember(Name = "all_replies")]
+ public bool? AllReplies { get; set; }
+
+ [DataMember(Name = "want_retweets")]
+ public bool? WantRetweets { get; set; }
+
+ [DataMember(Name = "can_dm")]
+ public bool CanDm { get; set; }
+
+ [DataMember(Name = "blocking")]
+ public bool? Blocking { get; set; }
+ }
+
+ /// <exception cref="SerializationException"/>
+ public static TwitterFriendship ParseJson(string json)
+ {
+ return MyCommon.CreateDataFromJson<TwitterFriendship>(json);
+ }
+ }
+}
--- /dev/null
+// OpenTween - Client of Twitter
+// Copyright (c) 2014 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
+// 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 <http://www.gnu.org/licenses/>, or write to
+// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
+// Boston, MA 02110-1301, USA.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OpenTween.Api
+{
+ [DataContract]
+ public class TwitterList
+ {
+ [DataMember(Name = "user")]
+ public TwitterUser User { get; set; }
+
+ [DataMember(Name = "following")]
+ public bool Following { get; set; }
+
+ [DataMember(Name = "created_at")]
+ public string CreatedAt { get; set; }
+
+ [DataMember(Name = "full_name")]
+ public string FullName { get; set; }
+
+ [DataMember(Name = "slug")]
+ public string Slug { get; set; }
+
+ [DataMember(Name = "id")]
+ public long Id { get; set; }
+
+ [DataMember(Name = "id_str")]
+ public string IdStr { get; set; }
+
+ [DataMember(Name = "name")]
+ public string Name { get; set; }
+
+ [DataMember(Name = "uri")]
+ public string Uri { get; set; }
+
+ [DataMember(Name = "subscriber_count")]
+ public int SubscriberCount { get; set; }
+
+ [DataMember(Name = "member_count")]
+ public int MemberCount { get; set; }
+
+ [DataMember(Name = "mode")]
+ public string Mode { get; set; }
+
+ [DataMember(Name = "description")]
+ public string Description { get; set; }
+
+ /// <exception cref="SerializationException"/>
+ public static TwitterList ParseJson(string json)
+ {
+ return MyCommon.CreateDataFromJson<TwitterList>(json);
+ }
+
+ /// <exception cref="SerializationException"/>
+ public static TwitterList[] ParseJsonArray(string json)
+ {
+ return MyCommon.CreateDataFromJson<TwitterList[]>(json);
+ }
+ }
+}
--- /dev/null
+// OpenTween - Client of Twitter
+// Copyright (c) 2014 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
+// 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 <http://www.gnu.org/licenses/>, or write to
+// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
+// Boston, MA 02110-1301, USA.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OpenTween.Api
+{
+ [DataContract]
+ public abstract class TwitterPageable<T>
+ {
+ public abstract T[] Items { get; }
+
+ [DataMember(Name = "next_cursor")]
+ public long NextCursor { get; set; }
+
+ [DataMember(Name = "next_cursor_str")]
+ public string NextCursorStr { get; set; }
+
+ [DataMember(Name = "previous_cursor")]
+ public long PreviousCursor { get; set; }
+
+ [DataMember(Name = "previous_cursor_str")]
+ public string PreviousCursorStr { get; set; }
+ }
+
+ [DataContract]
+ public class TwitterIds : TwitterPageable<long>
+ {
+ [DataMember(Name = "ids")]
+ public long[] Ids { get; set; }
+
+ [IgnoreDataMember]
+ public override long[] Items
+ {
+ get { return this.Ids; }
+ }
+
+ /// <exception cref="SerializationException"/>
+ public static TwitterIds ParseJson(string json)
+ {
+ return MyCommon.CreateDataFromJson<TwitterIds>(json);
+ }
+ }
+
+ [DataContract]
+ public class TwitterUsers : TwitterPageable<TwitterUser>
+ {
+ [DataMember(Name = "users")]
+ public TwitterUser[] Users { get; set; }
+
+ [IgnoreDataMember]
+ public override TwitterUser[] Items
+ {
+ get { return this.Users; }
+ }
+
+ /// <exception cref="SerializationException"/>
+ public static TwitterUsers ParseJson(string json)
+ {
+ return MyCommon.CreateDataFromJson<TwitterUsers>(json);
+ }
+ }
+
+ [DataContract]
+ public class TwitterLists : TwitterPageable<TwitterList>
+ {
+ [DataMember(Name = "lists")]
+ public TwitterList[] Lists { get; set; }
+
+ [IgnoreDataMember]
+ public override TwitterList[] Items
+ {
+ get { return this.Lists; }
+ }
+
+ /// <exception cref="SerializationException"/>
+ public static TwitterLists ParseJson(string json)
+ {
+ return MyCommon.CreateDataFromJson<TwitterLists>(json);
+ }
+ }
+}
--- /dev/null
+// OpenTween - Client of Twitter
+// Copyright (c) 2014 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
+// 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 <http://www.gnu.org/licenses/>, or write to
+// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
+// Boston, MA 02110-1301, USA.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OpenTween.Api
+{
+ // 参照: https://dev.twitter.com/docs/platform-objects/places
+
+ [DataContract]
+ public class TwitterPlace
+ {
+ [DataMember(Name = "bounding_box")]
+ public GeoJsonPolygon BoundingBox { get; set; }
+
+ [DataMember(Name = "country")]
+ public string Country { get; set; }
+
+ [DataMember(Name = "country_code")]
+ public string CountryCode { get; set; }
+
+ [DataMember(Name = "full_name")]
+ public string FullName { get; set; }
+
+ [DataMember(Name = "id")]
+ public string Id { get; set; }
+
+ [DataMember(Name = "name")]
+ public string Name { get; set; }
+
+ [DataMember(Name = "place_type")]
+ public string PlaceType { get; set; }
+
+ [DataMember(Name = "url")]
+ public string Url { get; set; }
+ }
+}
--- /dev/null
+// OpenTween - Client of Twitter
+// Copyright (c) 2014 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
+// 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 <http://www.gnu.org/licenses/>, or write to
+// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
+// Boston, MA 02110-1301, USA.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OpenTween.Api
+{
+ [DataContract]
+ public class TwitterSearchResult
+ {
+ [DataMember(Name = "statuses")]
+ public TwitterStatus[] Statuses { get; set; }
+
+ [DataMember(Name = "search_metadata")]
+ public TwitterSearchResult.Metadata SearchMetadata { get; set; }
+
+ [DataContract]
+ public class Metadata
+ {
+ [DataMember(Name = "max_id")]
+ public long MaxId { get; set; }
+
+ [DataMember(Name = "max_id_str")]
+ public string MaxIdStr { get; set; }
+
+ [DataMember(Name = "since_id")]
+ public long SinceId { get; set; }
+
+ [DataMember(Name = "since_id_str")]
+ public string SinceIdStr { get; set; }
+
+ [DataMember(Name = "refresh_url")]
+ public string RefreshUrl { get; set; }
+
+ [DataMember(Name = "next_results")]
+ public string NextResults { get; set; }
+
+ [DataMember(Name = "count")]
+ public int Count { get; set; }
+
+ [DataMember(Name = "completed_in")]
+ public double CompletedIn { get; set; }
+
+ [DataMember(Name = "query")]
+ public string Query { get; set; }
+ }
+
+ /// <exception cref="SerializationException"/>
+ public static TwitterSearchResult ParseJson(string json)
+ {
+ return MyCommon.CreateDataFromJson<TwitterSearchResult>(json);
+ }
+ }
+}
--- /dev/null
+// OpenTween - Client of Twitter
+// Copyright (c) 2014 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
+// 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 <http://www.gnu.org/licenses/>, or write to
+// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
+// Boston, MA 02110-1301, USA.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OpenTween.Api
+{
+ // 参照: https://dev.twitter.com/docs/platform-objects/tweets
+
+ [DataContract]
+ public class TwitterStatus
+ {
+ [DataMember(Name = "contributors", IsRequired = false)]
+ public TwitterStatus.Contributor[] Contributors { get; set; } // Nullable
+
+ [DataContract]
+ public class Contributor
+ {
+ [DataMember(Name = "id")]
+ public long Id { get; set; }
+
+ [DataMember(Name = "id_str")]
+ public string IdStr { get; set; }
+
+ [DataMember(Name = "screen_name")]
+ public string ScreenName { get; set; }
+ }
+
+ [DataMember(Name = "coordinates", IsRequired = false)]
+ public GeoJsonPoint Coordinates { get; set; }
+
+ [DataMember(Name = "created_at")]
+ public string CreatedAt { get; set; }
+
+ [DataMember(Name = "entities")]
+ public TwitterEntities Entities { get; set; }
+
+ [DataMember(Name = "favorite_count")]
+ public int? FavoriteCount { get; set; }
+
+ [DataMember(Name = "favorited")]
+ public bool? Favorited { get; set; }
+
+ [DataMember(Name = "filter_level")]
+ public string FilterLevel { get; set; }
+
+ [DataMember(Name = "id")]
+ public long Id { get; set; }
+
+ [DataMember(Name = "id_str")]
+ public string IdStr { get; set; }
+
+ [DataMember(Name = "in_reply_to_screen_name")]
+ public string InReplyToScreenName { get; set; } // Nullable
+
+ [DataMember(Name = "in_reply_to_status_id")]
+ public long? InReplyToStatusId { get; set; }
+
+ [DataMember(Name = "in_reply_to_status_id_str")]
+ public string InReplyToStatusIdStr { get; set; } // Nullable
+
+ [DataMember(Name = "in_reply_to_user_id")]
+ public long? InReplyToUserId { get; set; }
+
+ [DataMember(Name = "in_reply_to_user_id_str")]
+ public string InReplyToUserIdStr { get; set; } // Nullable
+
+ [DataMember(Name = "lang")]
+ public string Lang { get; set; } // Nullable
+
+ [DataMember(Name = "place", IsRequired = false)]
+ public TwitterPlace Place { get; set; }
+
+ [DataMember(Name = "possibly_sensitive")]
+ public bool? PossiblySensitive { get; set; }
+
+ [DataMember(Name = "retweet_count")]
+ public int RetweetCount { get; set; }
+
+ [DataMember(Name = "retweeted")]
+ public bool Retweeted { get; set; }
+
+ [DataMember(Name = "retweeted_status", IsRequired = false)]
+ public TwitterStatus RetweetedStatus { get; set; }
+
+ [DataMember(Name = "source")]
+ public string Source { get; set; }
+
+ [DataMember(Name = "text")]
+ public string Text { get; set; }
+
+ [DataMember(Name = "truncated")]
+ public bool Truncated { get; set; }
+
+ [DataMember(Name = "user")]
+ public TwitterUser User { get; set; }
+
+ [DataMember(Name = "withheld_copyright")]
+ public bool WithheldCopyright { get; set; }
+
+ [DataMember(Name = "withheld_in_countries")]
+ public string[] WithheldInCountries { get; set; }
+
+ [DataMember(Name = "withheld_scope")]
+ public string WithheldScope { get; set; }
+
+ /// <exception cref="SerializationException"/>
+ public static TwitterStatus ParseJson(string json)
+ {
+ return MyCommon.CreateDataFromJson<TwitterStatus>(json);
+ }
+
+ /// <exception cref="SerializationException"/>
+ public static TwitterStatus[] ParseJsonArray(string json)
+ {
+ return MyCommon.CreateDataFromJson<TwitterStatus[]>(json);
+ }
+ }
+
+ [DataContract]
+ public class TwitterDirectMessage
+ {
+ [DataMember(Name = "entities", IsRequired = false)]
+ public TwitterEntities Entities { get; set; }
+
+ [DataMember(Name = "created_at")]
+ public string CreatedAt { get; set; }
+
+ [DataMember(Name = "id")]
+ public long Id { get; set; }
+
+ [DataMember(Name = "id_str")]
+ public string IdStr { get; set; }
+
+ [DataMember(Name = "text")]
+ public string Text { get; set; }
+
+ [DataMember(Name = "sender_id")]
+ public long SenderId { get; set; }
+
+ [DataMember(Name = "sender_id_str")]
+ public string SenderIdStr { get; set; }
+
+ [DataMember(Name = "sender_screen_name")]
+ public string SenderScreenName { get; set; }
+
+ [DataMember(Name = "sender", IsRequired = false)]
+ public TwitterUser Sender { get; set; }
+
+ [DataMember(Name = "recipient_id")]
+ public long RecipientId { get; set; }
+
+ [DataMember(Name = "recipient_id_str")]
+ public string RecipientIdStr { get; set; }
+
+ [DataMember(Name = "recipient_screen_name")]
+ public string RecipientScreenName { get; set; }
+
+ [DataMember(Name = "recipient", IsRequired = false)]
+ public TwitterUser Recipient { get; set; }
+
+ /// <exception cref="SerializationException"/>
+ public static TwitterDirectMessage ParseJson(string json)
+ {
+ return MyCommon.CreateDataFromJson<TwitterDirectMessage>(json);
+ }
+
+ /// <exception cref="SerializationException"/>
+ public static TwitterDirectMessage[] ParseJsonArray(string json)
+ {
+ return MyCommon.CreateDataFromJson<TwitterDirectMessage[]>(json);
+ }
+ }
+}
--- /dev/null
+// OpenTween - Client of Twitter
+// Copyright (c) 2014 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
+// 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 <http://www.gnu.org/licenses/>, or write to
+// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
+// Boston, MA 02110-1301, USA.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OpenTween.Api
+{
+ [DataContract]
+ public class TwitterStreamEvent
+ {
+ [DataMember(Name = "target")]
+ public TwitterUser Target { get; set; }
+
+ [DataMember(Name = "source")]
+ public TwitterUser Source { get; set; }
+
+ [DataMember(Name = "event")]
+ public string Event { get; set; }
+
+ [DataMember(Name = "created_at")]
+ public string CreatedAt { get; set; }
+
+ /// <exception cref="SerializationException"/>
+ public static TwitterStreamEvent ParseJson(string json)
+ {
+ return MyCommon.CreateDataFromJson<TwitterStreamEvent>(json);
+ }
+ }
+
+ [DataContract]
+ public class TwitterStreamEvent<T> : TwitterStreamEvent
+ {
+ [DataMember(Name = "target_object")]
+ public T TargetObject { get; set; }
+
+ /// <exception cref="SerializationException"/>
+ public static new TwitterStreamEvent<T> ParseJson(string json)
+ {
+ return MyCommon.CreateDataFromJson<TwitterStreamEvent<T>>(json);
+ }
+ }
+
+ [DataContract]
+ public class TwitterStreamEventDirectMessage
+ {
+ [DataMember(Name = "direct_message")]
+ public TwitterDirectMessage DirectMessage;
+
+ /// <exception cref="SerializationException"/>
+ public static TwitterStreamEventDirectMessage ParseJson(string json)
+ {
+ return MyCommon.CreateDataFromJson<TwitterStreamEventDirectMessage>(json);
+ }
+ }
+}
--- /dev/null
+// OpenTween - Client of Twitter
+// Copyright (c) 2014 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
+// 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 <http://www.gnu.org/licenses/>, or write to
+// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
+// Boston, MA 02110-1301, USA.
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OpenTween.Api
+{
+ // 参照: https://dev.twitter.com/docs/platform-objects/users
+
+ [DataContract]
+ public class TwitterUser
+ {
+ [DataMember(Name = "contributors_enabled")]
+ public bool ContributorsEnabled { get; set; }
+
+ [DataMember(Name = "created_at")]
+ public string CreatedAt { get; set; }
+
+ [DataMember(Name = "description")]
+ public string Description { get; set; } // Nullable
+
+ [DataMember(Name = "entities", IsRequired = false)]
+ public TwitterUser.TwitterUserEntity Entities { get; set; }
+
+ [DataContract]
+ public class TwitterUserEntity
+ {
+ [DataMember(Name = "url", IsRequired = false)]
+ public TwitterEntities Url { get; set; }
+
+ [DataMember(Name = "description", IsRequired = false)]
+ public TwitterEntities Description { get; set; }
+ }
+
+ [DataMember(Name = "favourites_count")]
+ public int FavouritesCount { get; set; }
+
+ [DataMember(Name = "follow_request_sent")]
+ public bool? FollowRequestSent { get; set; }
+
+ [DataMember(Name = "following")]
+ public bool? Following { get; set; }
+
+ [DataMember(Name = "followers_count")]
+ public int FollowersCount { get; set; }
+
+ [DataMember(Name = "friends_count")]
+ public int FriendsCount { get; set; }
+
+ [DataMember(Name = "geo_enabled")]
+ public bool GeoEnabled { get; set; }
+
+ [DataMember(Name = "id")]
+ public long Id { get; set; }
+
+ [DataMember(Name = "id_str")]
+ public string IdStr { get; set; }
+
+ [DataMember(Name = "lang")]
+ public string Lang { get; set; }
+
+ [DataMember(Name = "listed_count")]
+ public int ListedCount { get; set; }
+
+ [DataMember(Name = "location")]
+ public string Location { get; set; } // Nullable
+
+ [DataMember(Name = "name")]
+ public string Name { get; set; }
+
+ [Obsolete]
+ [DataMember(Name = "notifications")]
+ public bool? Notifications { get; set; } // Nullable
+
+ [DataMember(Name = "profile_background_color")]
+ public string ProfileBackgroundColor { get; set; }
+
+ [DataMember(Name = "profile_background_image_url_https")]
+ public string ProfileBackgroundImageUrlHttps { get; set; }
+
+ [DataMember(Name = "profile_background_tile")]
+ public bool ProfileBackgroundTile { get; set; }
+
+ [DataMember(Name = "profile_image_url_https")]
+ public string ProfileImageUrlHttps { get; set; }
+
+ [DataMember(Name = "profile_link_color")]
+ public string ProfileLinkColor { get; set; }
+
+ [DataMember(Name = "profile_sidebar_border_color")]
+ public string ProfileSidebarBorderColor { get; set; }
+
+ [DataMember(Name = "profile_sidebar_fill_color")]
+ public string ProfileSidebarFillColor { get; set; }
+
+ [DataMember(Name = "profile_text_color")]
+ public string ProfileTextColor { get; set; }
+
+ [DataMember(Name = "profile_use_background_image")]
+ public bool ProfileUseBackgroundImage { get; set; }
+
+ [DataMember(Name = "protected")]
+ public bool Protected { get; set; }
+
+ [DataMember(Name = "screen_name")]
+ public string ScreenName { get; set; }
+
+ [DataMember(Name = "show_all_inline_media")]
+ public bool ShowAllInlineMedia { get; set; }
+
+ [DataMember(Name = "status", IsRequired = false)]
+ public TwitterStatus Status { get; set; } // Nullable
+
+ [DataMember(Name = "statuses_count")]
+ public int StatusesCount { get; set; }
+
+ [DataMember(Name = "time_zone")]
+ public string TimeZone { get; set; } // Nullable
+
+ [DataMember(Name = "url")]
+ public string Url { get; set; } // Nullable
+
+ [DataMember(Name = "utc_offset")]
+ public int? UtcOffset { get; set; }
+
+ [DataMember(Name = "verified")]
+ public bool Verified { get; set; }
+
+ /// <exception cref="SerializationException"/>
+ public static TwitterUser ParseJson(string json)
+ {
+ return MyCommon.CreateDataFromJson<TwitterUser>(json);
+ }
+ }
+}
using System.Threading;
using System.IO;
using System.Resources;
+using OpenTween.Api;
using OpenTween.Thumbnail;
using System.Threading.Tasks;
using OpenTween.Setting.Panel;
public bool IsRemoveSameEvent;
public bool IsNotifyUseGrowl;
- public TwitterDataModel.Configuration TwitterConfiguration = new TwitterDataModel.Configuration();
+ public TwitterConfiguration TwitterConfiguration = TwitterConfiguration.DefaultConfiguration();
private string _pin;
+++ /dev/null
-// OpenTween - Client of Twitter
-// Copyright (c) 2007-2011 kiri_feather (@kiri_feather) <kiri.feather@gmail.com>
-// (c) 2008-2011 Moz (@syo68k)
-// (c) 2008-2011 takeshik (@takeshik) <http://www.takeshik.org/>
-// (c) 2010-2011 anis774 (@anis774) <http://d.hatena.ne.jp/anis774/>
-// (c) 2010-2011 fantasticswallow (@f_swallow) <http://twitter.com/f_swallow>
-// (c) 2011 Egtra (@egtra) <http://dev.activebasic.com/egtra/>
-// (c) 2013 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
-// 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 <http://www.gnu.org/licenses/>, or write to
-// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
-// Boston, MA 02110-1301, USA.
-
-using System;
-using System.Runtime.Serialization;
-using System.Collections.Generic;
-
-namespace OpenTween
-{
- public class TwitterDataModel
- {
- [DataContract]
- public class Annotations
- {
- [DataMember(Name = "ConversationRole", IsRequired = false)] public string ConversationRole;
- [DataMember(Name = "FromUser", IsRequired = false)] public string FromUser;
- }
-
- [DataContract]
- public class Entity
- {
- [DataMember(Name = "indices")] public int[] Indices = new int[3];
- }
-
- [DataContract]
- public class SizeElement
- {
- [DataMember(Name = "w")] public int w;
- [DataMember(Name = "h")] public int h;
- [DataMember(Name = "resize")] public string Resize;
- }
-
- [DataContract]
- public class Sizes
- {
- [DataMember(Name = "large")] public SizeElement Large;
- [DataMember(Name = "medium")] public SizeElement Medium;
- [DataMember(Name = "small")] public SizeElement Small;
- [DataMember(Name = "thumb")] public SizeElement Thumb;
- }
-
- [DataContract]
- public class Media : Urls
- {
- [DataMember(Name = "id")] public long Id;
- [DataMember(Name = "media_url")] public string MediaUrl;
- [DataMember(Name = "media_url_https")] public string MediaUrlHttps;
- [DataMember(Name = "sizes")] public Sizes Sizes;
- [DataMember(Name = "type")] public string Type;
- }
-
- [DataContract]
- public class Urls : Entity
- {
- [DataMember(Name = "url")] public string Url;
- [DataMember(Name = "display_url")] public string DisplayUrl;
- [DataMember(Name = "expanded_url")] public string ExpandedUrl;
- }
-
- [DataContract]
- public class Hashtags : Entity
- {
- [DataMember(Name = "text")] public string Text;
- }
-
- [DataContract]
- public class UserMentions : Entity
- {
- [DataMember(Name = "screen_name")] public string ScreenName;
- [DataMember(Name = "name")] public string Name;
- [DataMember(Name = "id")] public Int64 Id;
- }
-
- [DataContract]
- public class Entities
- {
- [DataMember(Name = "urls")] public Urls[] Urls;
- [DataMember(Name = "hashtags")] public Hashtags[] Hashtags;
- [DataMember(Name = "user_mentions")] public UserMentions[] UserMentions;
- [DataMember(Name = "media", IsRequired = false)] public Media[] Media;
- }
-
- [DataContract]
- public class User
- {
- [DataMember(Name = "statuses_count")] public int StatusesCount;
- [DataMember(Name = "profile_sidebar_fill_color")] public string ProfileSidebarFillColor;
- [DataMember(Name = "show_all_inline_media")] public bool ShowAllInlineMedia;
- [DataMember(Name = "profile_use_background_image")] public bool ProfileUseBackgroundImage;
- [DataMember(Name = "contributors_enabled")] public bool ContributorsEnabled;
- [DataMember(Name = "profile_sidebar_border_color")] public string ProfileSidebarBorderColor;
- [DataMember(Name = "location")] public string Location;
- [DataMember(Name = "geo_enabled")] public bool GeoEnabled;
- [DataMember(Name = "description")] public string Description;
- [DataMember(Name = "friends_count")] public int FriendsCount;
- [DataMember(Name = "verified")] public bool Verified;
- [DataMember(Name = "favourites_count")] public int FavouritesCount;
- [DataMember(Name = "created_at")] public string CreatedAt;
- [DataMember(Name = "profile_background_color")] public string ProfileBackgroundColor;
- [DataMember(Name = "follow_request_sent")] public string FollowRequestSent;
- [DataMember(Name = "time_zone")] public string TimeZone;
- [DataMember(Name = "followers_count")] public int FollowersCount;
- [DataMember(Name = "url")] public string Url;
- [DataMember(Name = "profile_image_url_https")] public string ProfileImageUrlHttps;
- [DataMember(Name = "notifications")] public string Notifications;
- [DataMember(Name = "profile_text_color")] public string ProfileTextColor;
- [DataMember(Name = "protected")] public bool Protected;
- [DataMember(Name = "id_str")] public string IdStr;
- [DataMember(Name = "lang")] public string Lang;
- [DataMember(Name = "profile_background_image_url_https")] public string ProfileBackgroundImageUrlHttps;
- [DataMember(Name = "screen_name")] public string ScreenName;
- [DataMember(Name = "name")] public string Name;
- [DataMember(Name = "following")] public bool? Following;
- [DataMember(Name = "profile_link_color")] public string ProfileLinkColor;
- [DataMember(Name = "id")] public Int64 Id;
- [DataMember(Name = "listed_count")] public int ListedCount;
- [DataMember(Name = "profile_background_tile")] public bool ProfileBackgroundTile;
- [DataMember(Name = "utc_offset")] public int? UtcOffset;
- [DataMember(Name = "place", IsRequired = false)] public Place Place;
- [DataMember(Name = "status", IsRequired = false)] public Status Status;
- }
-
- [DataContract]
- public class Coordinates
- {
- [DataMember(Name = "type", IsRequired = false)] public string Type;
- [DataMember(Name = "coordinates", IsRequired = false)] public double[] coordinates = new double[2];
- }
-
- [DataContract]
- public class BoundingBox
- {
- [DataMember(Name = "type", IsRequired = false)] public string Type;
- [DataMember(Name = "coordinates", IsRequired = false)] public double[][][] Coordinates;
- }
-
- [DataContract]
- public class Attributes
- {
- [DataMember(Name = "street_address", IsRequired = false)] public string StreetAddress;
- }
-
- [DataContract]
- public class Place
- {
- [DataMember(Name = "url")] public string Url;
- [DataMember(Name = "bounding_box", IsRequired = false)] public BoundingBox BoundingBox;
- [DataMember(Name = "street_address", IsRequired = false)] public string StreetAddress;
- [DataMember(Name = "full_name")] public string FullName;
- [DataMember(Name = "name")] public string Name;
- //[DataMember(Name = "attributes", IsRequired = false)] public attributes attributes;
- [DataMember(Name = "country_code", IsRequired = false)] public string CountryCode;
- [DataMember(Name = "id")] public string Id;
- [DataMember(Name = "country")] public string Country;
- [DataMember(Name = "place_type")] public string PlaceType;
- }
-
- [DataContract]
- public class RetweetedStatus
- {
- [DataMember(Name = "coordinates", IsRequired = false)] public Coordinates Coordinates;
- [DataMember(Name = "in_reply_to_user_id")] public long? InReplyToUserId;
- [DataMember(Name = "source")] public string Source;
- [DataMember(Name = "user")] public User User;
- [DataMember(Name = "in_reply_to_screen_name")] public string InReplyToScreenName;
- [DataMember(Name = "created_at")] public string CreatedAt;
- [DataMember(Name = "contributors")] public int[] Contributors;
- [DataMember(Name = "favorited")] public bool Favorited;
- [DataMember(Name = "truncated")] public bool? Truncated;
- [DataMember(Name = "id")] public Int64 Id;
- [DataMember(Name = "annotations", IsRequired = false)] public Annotations Annotations;
- [DataMember(Name = "place", IsRequired = false)] public Place Place;
- [DataMember(Name = "in_reply_to_status_id")] public long? InReplyToStatusId;
- [DataMember(Name = "text")] public string Text;
- [DataMember(Name = "entities", IsRequired = false)] public Entities Entities;
- }
-
- [DataContract]
- public class Status
- {
- [DataMember(Name = "in_reply_to_status_id_str")] public string InReplyToStatusIdStr;
- [DataMember(Name = "contributors", IsRequired = false)] public int[] Contributors;
- [DataMember(Name = "in_reply_to_screen_name")] public string InReplyToScreenName;
- [DataMember(Name = "in_reply_to_status_id")] public long? InReplyToStatusId;
- [DataMember(Name = "in_reply_to_user_id_str")] public string InReplyToUserIdStr;
- [DataMember(Name = "retweet_count")] public int RetweetCount;
- [DataMember(Name = "created_at")] public string CreatedAt;
- [DataMember(Name = "retweeted")] public bool Retweeted;
- [DataMember(Name = "in_reply_to_user_id")] public long? InReplyToUserId;
- [DataMember(Name = "source")] public string Source;
- [DataMember(Name = "id_str")] public string IdStr;
- [DataMember(Name = "coordinates", IsRequired = false)] public Coordinates Coordinates;
- [DataMember(Name = "truncated")] public string Truncated;
- [DataMember(Name = "place", IsRequired = false)] public Place Place;
- [DataMember(Name = "user")] public User User;
- [DataMember(Name = "retweeted_status", IsRequired = false)] public RetweetedStatus RetweetedStatus;
- [DataMember(Name = "id")] public Int64 Id;
- [DataMember(Name = "favorited")] public bool Favorited;
- [DataMember(Name = "text")] public string Text;
- [DataMember(Name = "entities", IsRequired = false)] public Entities Entities;
- }
-
- [DataContract]
- public class TargetObject : Status
- {
- [DataMember(Name = "mode")] public string Mode;
- [DataMember(Name = "description")] public string Description;
- [DataMember(Name = "slug")] public string Slug;
- [DataMember(Name = "uri")] public string Uri;
- [DataMember(Name = "member_count")] public int MemberCount;
- [DataMember(Name = "full_name")] public string FullName;
- [DataMember(Name = "subscriber_count")] public int SubscriberCount;
- [DataMember(Name = "name")] public string Name;
- [DataMember(Name = "following")] public bool Following;
- }
-
- [DataContract]
- public class Directmessage
- {
- [DataMember(Name = "created_at")] public string CreatedAt;
- [DataMember(Name = "sender_id")] public Int64 SenderId;
- [DataMember(Name = "sender_screen_name")] public string SenderScreenName;
- [DataMember(Name = "sender")] public User Sender;
- [DataMember(Name = "id_str")] public string IdStr;
- [DataMember(Name = "recipient")] public User Recipient;
- [DataMember(Name = "recipient_screen_name")] public string RecipientScreenName;
- [DataMember(Name = "recipient_id")] public Int64 RecipientId;
- [DataMember(Name = "id")] public Int64 Id;
- [DataMember(Name = "text")] public string Text;
- [DataMember(Name = "entities", IsRequired = false)] public Entities Entities;
- }
-
- [DataContract]
- public class Friendsevent
- {
- [DataMember(Name = "friends")] public Int64[] Friends;
- }
-
- [DataContract]
- public class DeletedStatusContent
- {
- [DataMember(Name = "id")] public Int64 Id;
- [DataMember(Name = "user_id")] public Int64 UserId;
- }
-
- [DataContract]
- public class DeletedStatus
- {
- [DataMember(Name = "status")] public DeletedStatusContent Status;
- }
-
- [DataContract]
- public class DeleteEvent
- {
- [DataMember(Name = "delete")] public DeletedStatus Event;
- }
-
- [DataContract]
- public class DeletedDirectmessage
- {
- [DataMember(Name = "direct_message")] public DeletedStatusContent Directmessage;
- }
-
- [DataContract]
- public class DeleteDirectmessageEvent
- {
- [DataMember(Name = "delete")] public DeletedDirectmessage Event;
- }
- [DataContract]
- public class DirectmessageEvent
- {
- [DataMember(Name = "direct_message")] public Directmessage Directmessage;
- }
-
- [DataContract]
- public class TrackCount
- {
- [DataMember(Name = "track")] public int Track;
- }
-
- [DataContract]
- public class LimitEvent
- {
- [DataMember(Name = "limit")] public TrackCount Limit;
- }
-
- [DataContract]
- public class EventData
- {
- [DataMember(Name = "target")] public User Target;
- [DataMember(Name = "target_object", IsRequired = false)] public TargetObject TargetObject;
- [DataMember(Name = "created_at")] public string CreatedAt;
- [DataMember(Name = "event")] public string Event;
- [DataMember(Name = "source")] public User Source;
- }
-
- [DataContract]
- public class RelatedTweet
- {
- [DataMember(Name = "annotations")] public Annotations Annotations;
- [DataMember(Name = "kind")] public string Kind;
- [DataMember(Name = "score")] public double Score;
- [DataMember(Name = "value")] public Status Status;
- }
-
- [DataContract]
- public class RelatedResult
- {
- [DataMember(Name = "annotations")] public Annotations Annotations;
- [DataMember(Name = "groupName")] public string GroupName;
- [DataMember(Name = "resultType")] public string ResultType;
- [DataMember(Name = "results")] public RelatedTweet[] Results;
- [DataMember(Name = "score")] public double Score;
- }
-
- [DataContract]
- public class RelationshipResult
- {
- [DataMember(Name = "followed_by")] public bool FollowedBy;
- [DataMember(Name = "following")] public bool Following;
- }
-
- [DataContract]
- public class RelationshipUsers
- {
- [DataMember(Name = "target")] public RelationshipResult Target;
- [DataMember(Name = "source")] public RelationshipResult Source;
- }
-
- [DataContract]
- public class Relationship
- {
- [DataMember(Name = "relationship")] public RelationshipUsers relationship;
- }
-
- [DataContract]
- public class Ids
- {
- [DataMember(Name = "ids")] public long[] Id;
- [DataMember(Name = "next_cursor")] public long NextCursor;
- [DataMember(Name = "previous_cursor")] public long PreviousCursor;
- }
-
- [DataContract]
- public class RateLimitStatus
- {
- [DataMember(Name = "reset_time_in_seconds")] public int ResetTimeInSeconds;
- [DataMember(Name = "remaining_hits")] public int RemainingHits;
- [DataMember(Name = "reset_time")] public string ResetTime;
- [DataMember(Name = "hourly_limit")] public int HourlyLimit;
- [DataMember(Name = "photos")] public MediaRateLimitStatus Photos;
- }
-
- [DataContract]
- public class MediaRateLimitStatus
- {
- [DataMember(Name = "reset_time_in_seconds")] public int RestTimeInSeconds;
- [DataMember(Name = "remaining_hits")] public int RemainingHits;
- [DataMember(Name = "reset_time")] public string ResetTime;
- [DataMember(Name = "daily_limit")] public int DailyLimit;
- }
-
- [DataContract]
- public class ListElementData
- {
- [DataMember(Name = "mode")] public string Mode;
- [DataMember(Name = "uri")] public string Uri;
- [DataMember(Name = "member_count")] public int MemberCount;
- [DataMember(Name = "slug")] public string Slug;
- [DataMember(Name = "full_name")] public string FullName;
- [DataMember(Name = "user")] public User User;
- [DataMember(Name = "following")] public bool Following;
- [DataMember(Name = "subscriber_count")] public int SubscriberCount;
- [DataMember(Name = "description")] public string Description;
- [DataMember(Name = "name")] public string Name;
- [DataMember(Name = "id")] public long Id;
- }
-
- [DataContract]
- public class Lists
- {
- [DataMember(Name = "lists")] public ListElementData[] lists;
- [DataMember(Name = "next_cursor")] public long NextCursor;
- [DataMember(Name = "previous_cursor")] public long PreviousCursor;
- }
-
- [DataContract]
- public class Users
- {
- [DataMember(Name = "users")] public User[] users;
- [DataMember(Name = "next_cursor")] public long NextCursor;
- [DataMember(Name = "previous_cursor")] public long PreviousCursor;
- }
-
- [DataContract]
- public class ErrorResponse
- {
- [DataMember(Name = "errors")] public ErrorItem[] Errors;
- }
-
- [DataContract]
- public class ErrorItem
- {
- [DataMember(Name = "code")] public ErrorCode Code;
- [DataMember(Name = "message")] public string Message;
-
- public override string ToString()
- {
- if (Enum.IsDefined(typeof(ErrorCode), this.Code))
- return this.Code.ToString();
- else
- return this.Message;
- }
- }
-
- /// <summary>
- /// Twitter API から返されるエラーコード
- /// </summary>
- /// <remarks>
- /// https://dev.twitter.com/docs/error-codes-responses を参照
- /// </remarks>
- public enum ErrorCode : int
- {
- /// <summary>
- /// 不正なリクエスト等によって認証を完了できない場合に発生する。大体クライアントのせい
- /// </summary>
- AuthError = 32,
- /// <summary>
- /// 指定されたリソースが存在しません。HTTP 404 と同等
- /// </summary>
- NotFound = 34,
- /// <summary>
- /// アカウントが凍結されています
- /// </summary>
- SuspendedAccount = 64,
- /// <summary>
- /// REST API v1 は星になりました
- /// </summary>
- APIv1Retired = 68,
- /// <summary>
- /// レートリミットに到達しました
- /// </summary>
- RateLimit = 88,
- /// <summary>
- /// アクセストークンが無効です。不正なトークンまたはユーザーによって失効されています
- /// </summary>
- InvalidToken = 89,
- /// <summary>
- /// サーバーの過負荷によって一時的にアクセスできません
- /// </summary>
- OverCapacity = 130,
- /// <summary>
- /// サーバーの内部エラー
- /// </summary>
- InternalError = 131,
- /// <summary>
- /// oauth_timestamp の時刻が無効。クライアントかサーバーの時計が大幅にずれている
- /// </summary>
- TimestampOutOfRange = 135,
- /// <summary>
- /// ユーザーからブロックされている (公式ドキュメントに記述無し)
- /// </summary>
- Blocked = 136,
- /// <summary>
- /// 既にふぁぼっているツイートをふぁぼろうとした (公式ドキュメントに記述無し)
- /// </summary>
- AlreadyFavorited = 139,
- /// <summary>
- /// フォローの追加が制限されています
- /// </summary>
- FollowLimit = 161,
- /// <summary>
- /// 投稿されたステータスが重複しています
- /// </summary>
- DuplicateStatus = 187,
- /// <summary>
- /// 認証が必要な API で認証データが含まれていない、または認証データが不正
- /// </summary>
- AuthenticationRequired = 215,
- /// <summary>
- /// 廃止されたエンドポイント
- /// </summary>
- RetiredEndpoint = 251,
- }
-
- [DataContract]
- public class SearchResult
- {
- [DataMember(Name = "statuses")] public List<Status> Statuses;
- [DataMember(Name = "search_metadata")] public SearchMetadata SearchMetadata;
- }
-
- [DataContract]
- public class SearchMetadata
- {
- [DataMember(Name = "max_id")] public long MaxId;
- [DataMember(Name = "since_id")] public long SinceId;
- [DataMember(Name = "refresh_url")] public string RefreshUrl;
- [DataMember(Name = "next_results")] public string NextResults;
- [DataMember(Name = "count")] public int Count;
- [DataMember(Name = "completed_in")] public double CompletedIn;
- [DataMember(Name = "since_id_str")] public string SinceIdStr;
- [DataMember(Name = "query")] public string Query;
- [DataMember(Name = "max_id_str")] public string MaxIdStr;
- }
-
- [DataContract]
- public class PhotoSize
- {
- [DataMember(Name = "h")] public int Height;
- [DataMember(Name = "w")] public int Width;
- [DataMember(Name = "resize")] public string Resize;
- }
-
- [DataContract]
- public class PhotoType
- {
- [DataMember(Name = "large")] public PhotoSize LargeSize;
- [DataMember(Name = "medium")] public PhotoSize MediumSize;
- [DataMember(Name = "small")] public PhotoSize SmallSize;
- [DataMember(Name = "thumb")] public PhotoSize ThumbSize;
- }
-
- [DataContract]
- public class Configuration
- {
- [DataMember(Name = "characters_reserved_per_media")] public int CharactersReservedPerMedia = 20;
- [DataMember(Name = "photo_size_limit")] public int PhotoSizeLimit;
- [DataMember(Name = "photo_sizes")] public PhotoType PhotoSizes;
- [DataMember(Name = "non_username_paths")] public string[] NonUsernamePaths;
- [DataMember(Name = "short_url_length")] public int ShortUrlLength = 19;
- [DataMember(Name = "short_url_length_https")] public int ShortUrlLengthHttps = 20;
- [DataMember(Name = "max_media_per_upload")] public int MaxMediaPerUpload;
- }
- }
-}
using System.Collections.Generic;
using System.Xml.Serialization;
+using OpenTween.Api;
namespace OpenTween
{
{
}
- public ListElement(TwitterDataModel.ListElementData listElementData, dynamic tw)
+ public ListElement(TwitterList listElementData, dynamic tw)
{
this.Description = listElementData.Description;
this.Id = listElementData.Id;
</ItemGroup>
<ItemGroup>
<Compile Include="Api\ApiLimit.cs" />
+ <Compile Include="Api\GeoJson.cs" />
+ <Compile Include="Api\TwitterConfiguration.cs" />
+ <Compile Include="Api\TwitterEntity.cs" />
+ <Compile Include="Api\TwitterError.cs" />
+ <Compile Include="Api\TwitterFriendship.cs" />
+ <Compile Include="Api\TwitterList.cs" />
+ <Compile Include="Api\TwitterPageable.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Api\TwitterPlace.cs" />
+ <Compile Include="Api\TwitterSearchResult.cs" />
+ <Compile Include="Api\TwitterStatus.cs" />
+ <Compile Include="Api\TwitterStreamEvent.cs" />
+ <Compile Include="Api\TwitterUser.cs" />
<Compile Include="Api\TwitterApiAccessLevel.cs" />
<Compile Include="Api\TwitterApiStatus.cs" />
<Compile Include="ApplicationEvents.cs">
<Compile Include="Connection\TwitPic.cs" />
<Compile Include="Connection\TwitterPhoto.cs" />
<Compile Include="Connection\yfrog.cs" />
- <Compile Include="DataModel.cs" />
<Compile Include="DetailsListView.cs">
<SubType>Component</SubType>
</Compile>
{
public Twitter tw;
public string id;
- public TwitterDataModel.User user;
+ public TwitterUser user;
}
private void GetUserInfo_DoWork(object sender, DoWorkEventArgs e)
private void doShowUserStatus(string id, bool ShowInputDialog)
{
- TwitterDataModel.User user = null;
+ TwitterUser user = null;
GetUserInfoArgs args = new GetUserInfoArgs();
if (ShowInputDialog)
{
}
}
- private void doShowUserStatus(TwitterDataModel.User user)
+ private void doShowUserStatus(TwitterUser user)
{
using (var userinfo = new UserInfoDialog())
{
using System.Globalization;
using System.Linq;
using System.Text;
+using OpenTween.Api;
namespace OpenTween
{
/// </summary>
public class TweetFormatter
{
- public static string AutoLinkHtml(string text, TwitterDataModel.Entities entities)
+ public static string AutoLinkHtml(string text, TwitterEntities entities)
{
if (entities == null)
- return AutoLinkHtml(text, Enumerable.Empty<TwitterDataModel.Entity>());
+ return AutoLinkHtml(text, Enumerable.Empty<TwitterEntity>());
- if (entities.Urls == null)
- entities.Urls = new TwitterDataModel.Urls[0];
+ var urls = entities.Urls ?? new TwitterEntityUrl[0];
+ var hashtags = entities.Hashtags ?? new TwitterEntityHashtag[0];
+ var mentions = entities.UserMentions ?? new TwitterEntityMention[0];
+ var media = entities.Media ?? new TwitterEntityMedia[0];
- if (entities.Hashtags == null)
- entities.Hashtags = new TwitterDataModel.Hashtags[0];
-
- if (entities.UserMentions == null)
- entities.UserMentions = new TwitterDataModel.UserMentions[0];
-
- if (entities.Media == null)
- entities.Media = new TwitterDataModel.Media[0];
-
- var entitiesQuery = entities.Urls.Cast<TwitterDataModel.Entity>()
- .Concat(entities.Hashtags)
- .Concat(entities.UserMentions)
- .Concat(entities.Media)
+ var entitiesQuery = urls.Cast<TwitterEntity>()
+ .Concat(hashtags)
+ .Concat(mentions)
+ .Concat(media)
.Where(x => x != null)
.Where(x => x.Indices != null && x.Indices.Length == 2);
return string.Concat(AutoLinkHtmlInternal(text, entitiesQuery));
}
- public static string AutoLinkHtml(string text, IEnumerable<TwitterDataModel.Entity> entities)
+ public static string AutoLinkHtml(string text, IEnumerable<TwitterEntity> entities)
{
if (entities == null)
- entities = Enumerable.Empty<TwitterDataModel.Entity>();
+ entities = Enumerable.Empty<TwitterEntity>();
var entitiesQuery = entities
.Where(x => x != null)
return string.Concat(AutoLinkHtmlInternal(text, entitiesQuery));
}
- private static IEnumerable<string> AutoLinkHtmlInternal(string text, IEnumerable<TwitterDataModel.Entity> entities)
+ private static IEnumerable<string> AutoLinkHtmlInternal(string text, IEnumerable<TwitterEntity> entities)
{
var curIndex = 0;
var targetText = text.Substring(startIndex, endIndex - startIndex);
- if (entity is TwitterDataModel.Urls)
- yield return FormatUrlEntity(targetText, (TwitterDataModel.Urls)entity);
- else if (entity is TwitterDataModel.Hashtags)
- yield return FormatHashtagEntity(targetText, (TwitterDataModel.Hashtags)entity);
- else if (entity is TwitterDataModel.UserMentions)
- yield return FormatMentionEntity(targetText, (TwitterDataModel.UserMentions)entity);
+ if (entity is TwitterEntityUrl)
+ yield return FormatUrlEntity(targetText, (TwitterEntityUrl)entity);
+ else if (entity is TwitterEntityHashtag)
+ yield return FormatHashtagEntity(targetText, (TwitterEntityHashtag)entity);
+ else if (entity is TwitterEntityMention)
+ yield return FormatMentionEntity(targetText, (TwitterEntityMention)entity);
else
yield return t(e(targetText));
/// <summary>
/// エンティティの Indices をサロゲートペアを考慮して調整します
/// </summary>
- private static IEnumerable<TwitterDataModel.Entity> FixEntityIndices(string text, IEnumerable<TwitterDataModel.Entity> entities)
+ private static IEnumerable<TwitterEntity> FixEntityIndices(string text, IEnumerable<TwitterEntity> entities)
{
var curIndex = 0;
var indexOffset = 0; // サロゲートペアによる indices のズレを表す
}
}
- private static string FormatUrlEntity(string targetText, TwitterDataModel.Urls entity)
+ private static string FormatUrlEntity(string targetText, TwitterEntityUrl entity)
{
string expandedUrl;
return "<a href=\"" + e(entity.Url) + "\" title=\"" + e(expandedUrl) + "\">" + t(e(entity.DisplayUrl)) + "</a>";
}
- private static string FormatHashtagEntity(string targetText, TwitterDataModel.Hashtags entity)
+ private static string FormatHashtagEntity(string targetText, TwitterEntityHashtag entity)
{
return "<a class=\"hashtag\" href=\"https://twitter.com/search?q=%23" + eu(entity.Text) + "\">" + t(e(targetText)) + "</a>";
}
- private static string FormatMentionEntity(string targetText, TwitterDataModel.UserMentions entity)
+ private static string FormatMentionEntity(string targetText, TwitterEntityMention entity)
{
return "<a class=\"mention\" href=\"https://twitter.com/" + eu(entity.ScreenName) + "\">" + t(e(targetText)) + "</a>";
}
if (res == HttpStatusCode.OK)
{
Twitter.AccountState = MyCommon.ACCOUNT_STATE.Valid;
- TwitterDataModel.User user;
+ TwitterUser user;
try
{
- user = MyCommon.CreateDataFromJson<TwitterDataModel.User>(content);
+ user = TwitterUser.ParseJson(content);
}
catch(SerializationException)
{
}
static private PostInfo _prev = new PostInfo("", "", "", "");
- private bool IsPostRestricted(TwitterDataModel.Status status)
+ private bool IsPostRestricted(TwitterStatus status)
{
var _current = new PostInfo("", "", "", "");
var err = this.CheckStatusCode(res, content);
if (err != null) return err;
- TwitterDataModel.Status status;
+ TwitterStatus status;
try
{
- status = MyCommon.CreateDataFromJson<TwitterDataModel.Status>(content);
+ status = TwitterStatus.ParseJson(content);
}
catch(SerializationException ex)
{
var err = this.CheckStatusCode(res, content);
if (err != null) return err;
- TwitterDataModel.Status status;
+ TwitterStatus status;
try
{
- status = MyCommon.CreateDataFromJson<TwitterDataModel.Status>(content);
+ status = TwitterStatus.ParseJson(content);
}
catch(SerializationException ex)
{
var err = this.CheckStatusCode(res, content);
if (err != null) return err;
- TwitterDataModel.Directmessage status;
+ TwitterDirectMessage status;
try
{
- status = MyCommon.CreateDataFromJson<TwitterDataModel.Directmessage>(content);
+ status = TwitterDirectMessage.ParseJson(content);
}
catch(SerializationException ex)
{
var err = this.CheckStatusCode(res, content);
if (err != null) return err;
- TwitterDataModel.Status status;
+ TwitterStatus status;
try
{
- status = MyCommon.CreateDataFromJson<TwitterDataModel.Status>(content);
+ status = TwitterStatus.ParseJson(content);
}
catch(SerializationException ex)
{
try
{
- var relation = MyCommon.CreateDataFromJson<TwitterDataModel.Relationship>(content);
- isFollowing = relation.relationship.Source.Following;
- isFollowed = relation.relationship.Source.FollowedBy;
+ var friendship = TwitterFriendship.ParseJson(content);
+ isFollowing = friendship.Relationship.Source.Following;
+ isFollowed = friendship.Relationship.Source.FollowedBy;
return "";
}
catch(SerializationException ex)
}
}
- public string GetUserInfo(string screenName, ref TwitterDataModel.User user)
+ public string GetUserInfo(string screenName, ref TwitterUser user)
{
if (MyCommon._endingFlag) return "";
try
{
- user = MyCommon.CreateDataFromJson<TwitterDataModel.User>(content);
+ user = TwitterUser.ParseJson(content);
}
catch (SerializationException ex)
{
var err = this.CheckStatusCode(res, content);
if (err != null) return err;
- TwitterDataModel.Status status;
+ TwitterStatus status;
try
{
- status = MyCommon.CreateDataFromJson<TwitterDataModel.Status>(content);
+ status = TwitterStatus.ParseJson(content);
}
catch (SerializationException ex)
{
err = this.CheckStatusCode(res, content);
if (err != null) return err;
- TwitterDataModel.Status status;
+ TwitterStatus status;
try
{
- status = MyCommon.CreateDataFromJson<TwitterDataModel.Status>(content);
+ status = TwitterStatus.ParseJson(content);
}
catch (SerializationException ex)
{
MyCommon.TraceOut(ex, MethodBase.GetCurrentMethod().Name + " " + content);
return "Err:Invalid Json!";
}
- if (status.Favorited)
+ if (status.Favorited == true)
{
return "";
}
return this.CheckStatusCode(res, content) ?? "";
}
- public TwitterDataModel.User PostUpdateProfile(string name, string url, string location, string description)
+ public TwitterUser PostUpdateProfile(string name, string url, string location, string description)
{
if (Twitter.AccountState != MyCommon.ACCOUNT_STATE.Valid)
throw new WebApiException("AccountState invalid");
try
{
- return MyCommon.CreateDataFromJson<TwitterDataModel.User>(content);
+ return TwitterUser.ParseJson(content);
}
catch (SerializationException e)
{
var err = this.CheckStatusCode(res, content);
if (err != null) return err;
- List<TwitterDataModel.Status> items;
+ TwitterStatus[] items;
try
{
- items = MyCommon.CreateDataFromJson<List<TwitterDataModel.Status>>(content);
+ items = TwitterStatus.ParseJsonArray(content);
}
catch(SerializationException ex)
{
var err = this.CheckStatusCode(res, content);
if (err != null) return err;
- TwitterDataModel.Status status;
+ TwitterStatus status;
try
{
- status = MyCommon.CreateDataFromJson<TwitterDataModel.Status>(content);
+ status = TwitterStatus.ParseJson(content);
}
catch(SerializationException ex)
{
return r;
}
- private PostClass CreatePostsFromStatusData(TwitterDataModel.Status status)
+ private PostClass CreatePostsFromStatusData(TwitterStatus status)
{
var post = new PostClass();
- TwitterDataModel.Entities entities;
+ TwitterEntities entities;
post.StatusId = status.Id;
if (status.RetweetedStatus != null)
var tc = TabInformations.GetInstance().GetTabByType(MyCommon.TabUsageType.Favorites);
post.IsFav = tc.Contains(retweeted.Id);
- if (retweeted.Coordinates != null) post.PostGeo = new PostClass.StatusGeo { Lng = retweeted.Coordinates.coordinates[0], Lat = retweeted.Coordinates.coordinates[1] };
+ if (retweeted.Coordinates != null) post.PostGeo = new PostClass.StatusGeo { Lng = retweeted.Coordinates.Coordinates[0], Lat = retweeted.Coordinates.Coordinates[1] };
//以下、ユーザー情報
var user = retweeted.User;
post.InReplyToUser = status.InReplyToScreenName;
post.InReplyToUserId = status.InReplyToUserId;
- if (status.Coordinates != null) post.PostGeo = new PostClass.StatusGeo { Lng = status.Coordinates.coordinates[0], Lat = status.Coordinates.coordinates[1] };
+ if (status.Coordinates != null) post.PostGeo = new PostClass.StatusGeo { Lng = status.Coordinates.Coordinates[0], Lat = status.Coordinates.Coordinates[1] };
//以下、ユーザー情報
var user = status.User;
private string CreatePostsFromJson(string content, MyCommon.WORKERTYPE gType, TabClass tab, bool read, int count, ref long minimumId)
{
- List<TwitterDataModel.Status> items;
+ TwitterStatus[] items;
try
{
- items = MyCommon.CreateDataFromJson<List<TwitterDataModel.Status>>(content);
+ items = TwitterStatus.ParseJsonArray(content);
}
catch(SerializationException ex)
{
private string CreatePostsFromSearchJson(string content, TabClass tab, bool read, int count, ref long minimumId, bool more)
{
- TwitterDataModel.SearchResult items;
+ TwitterSearchResult items;
try
{
- items = MyCommon.CreateDataFromJson<TwitterDataModel.SearchResult>(content);
+ items = TwitterSearchResult.ParseJson(content);
}
catch (SerializationException ex)
{
private string CreateDirectMessagesFromJson(string content, MyCommon.WORKERTYPE gType, bool read)
{
- List<TwitterDataModel.Directmessage> item;
+ TwitterDirectMessage[] item;
try
{
if (gType == MyCommon.WORKERTYPE.UserStream)
{
- var itm = MyCommon.CreateDataFromJson<List<TwitterDataModel.DirectmessageEvent>>(content);
- item = new List<TwitterDataModel.Directmessage>();
- foreach (var dat in itm)
- {
- item.Add(dat.Directmessage);
- }
+ item = new[] { TwitterStreamEventDirectMessage.ParseJson(content).DirectMessage };
}
else
{
- item = MyCommon.CreateDataFromJson<List<TwitterDataModel.Directmessage>>(content);
+ item = TwitterDirectMessage.ParseJsonArray(content);
}
}
catch(SerializationException ex)
post.IsFav = false;
//以下、ユーザー情報
- TwitterDataModel.User user;
+ TwitterUser user;
if (gType == MyCommon.WORKERTYPE.UserStream)
{
if (twCon.AuthenticatedUsername.Equals(message.Recipient.ScreenName, StringComparison.CurrentCultureIgnoreCase))
var err = this.CheckStatusCode(res, content);
if (err != null) return err;
- List<TwitterDataModel.Status> item;
+ TwitterStatus[] item;
try
{
- item = MyCommon.CreateDataFromJson<List<TwitterDataModel.Status>>(content);
+ item = TwitterStatus.ParseJsonArray(content);
}
catch(SerializationException ex)
{
foreach (var status in item)
{
var post = new PostClass();
- TwitterDataModel.Entities entities;
+ TwitterEntities entities;
try
{
return "";
}
- private string ReplaceTextFromApi(string text, TwitterDataModel.Entities entities)
+ private string ReplaceTextFromApi(string text, TwitterEntities entities)
{
if (entities != null)
{
do
{
var ret = this.GetFollowerIdsApi(ref cursor);
- newFollowerIds.AddRange(ret.Id);
+ newFollowerIds.AddRange(ret.Ids);
cursor = ret.NextCursor;
} while (cursor != 0);
}
}
- private TwitterDataModel.Ids GetFollowerIdsApi(ref long cursor)
+ private TwitterIds GetFollowerIdsApi(ref long cursor)
{
if (Twitter.AccountState != MyCommon.ACCOUNT_STATE.Valid)
throw new WebApiException("AccountState invalid");
try
{
- var ret = MyCommon.CreateDataFromJson<TwitterDataModel.Ids>(content);
+ var ret = TwitterIds.ParseJson(content);
- if (ret.Id == null)
+ if (ret.Ids == null)
{
var ex = new WebApiException("Err: ret.id == null (GetFollowerIdsApi)", content);
MyCommon.ExceptionOut(ex);
/// t.co の文字列長などの設定情報を取得します
/// </summary>
/// <exception cref="WebApiException"/>
- public TwitterDataModel.Configuration ConfigurationApi()
+ public TwitterConfiguration ConfigurationApi()
{
HttpStatusCode res;
var content = "";
try
{
- return MyCommon.CreateDataFromJson<TwitterDataModel.Configuration>(content);
+ return TwitterConfiguration.ParseJson(content);
}
catch(SerializationException e)
{
try
{
- lists = MyCommon.CreateDataFromJson<List<TwitterDataModel.ListElementData>>(content)
+ lists = TwitterList.ParseJsonArray(content)
.Select(x => new ListElement(x, this));
}
catch (SerializationException ex)
try
{
- lists = lists.Concat(MyCommon.CreateDataFromJson<List<TwitterDataModel.ListElementData>>(content)
+ lists = lists.Concat(TwitterList.ParseJsonArray(content)
.Select(x => new ListElement(x, this)));
}
catch (SerializationException ex)
try
{
- var le = MyCommon.CreateDataFromJson<TwitterDataModel.ListElementData>(content);
+ var le = TwitterList.ParseJson(content);
var newList = new ListElement(le, this);
list.Description = newList.Description;
list.Id = newList.Id;
try
{
- var users = MyCommon.CreateDataFromJson<TwitterDataModel.Users>(content);
- Array.ForEach<TwitterDataModel.User>(
- users.users,
- new Action<TwitterDataModel.User>(u => lists.Add(new UserInfo(u))));
+ var users = TwitterUsers.ParseJson(content);
+ Array.ForEach<TwitterUser>(
+ users.Users,
+ u => lists.Add(new UserInfo(u)));
cursor = users.NextCursor;
return "";
}
try
{
- var le = MyCommon.CreateDataFromJson<TwitterDataModel.ListElementData>(content);
+ var le = TwitterList.ParseJson(content);
TabInformations.GetInstance().SubscribableLists.Add(new ListElement(le, this));
return "";
}
try
{
- var u = MyCommon.CreateDataFromJson<TwitterDataModel.User>(content);
+ var u = TwitterUser.ParseJson(content);
value = true;
return "";
}
return retStr;
}
- public async Task<string> CreateHtmlAnchorAsync(string text, List<string> AtList, TwitterDataModel.Entities entities, Dictionary<string, string> media)
+ public async Task<string> CreateHtmlAnchorAsync(string text, List<string> AtList, TwitterEntities entities, Dictionary<string, string> media)
{
if (entities != null)
{
}
[Obsolete]
- public string CreateHtmlAnchor(string text, List<string> AtList, TwitterDataModel.Entities entities, Dictionary<string, string> media)
+ public string CreateHtmlAnchor(string text, List<string> AtList, TwitterEntities entities, Dictionary<string, string> media)
{
return this.CreateHtmlAnchorAsync(text, AtList, entities, media).Result;
}
do
{
var ret = this.GetBlockIdsApi(cursor);
- newBlockIds.AddRange(ret.Id);
+ newBlockIds.AddRange(ret.Ids);
cursor = ret.NextCursor;
} while (cursor != 0);
TabInformations.GetInstance().BlockIds = newBlockIds;
}
- public TwitterDataModel.Ids GetBlockIdsApi(long cursor)
+ public TwitterIds GetBlockIdsApi(long cursor)
{
if (Twitter.AccountState != MyCommon.ACCOUNT_STATE.Valid)
throw new WebApiException("AccountState invalid");
try
{
- return MyCommon.CreateDataFromJson<TwitterDataModel.Ids>(content);
+ return TwitterIds.ParseJson(content);
}
catch(SerializationException e)
{
try
{
- var errors = MyCommon.CreateDataFromJson<TwitterDataModel.ErrorResponse>(responseText).Errors;
+ var errors = TwitterError.ParseJson(responseText).Errors;
if (errors == null || !errors.Any())
{
return "Err:" + httpStatus + "(" + callerMethodName + ")";
foreach (var error in errors)
{
- if (error.Code == TwitterDataModel.ErrorCode.InvalidToken ||
- error.Code == TwitterDataModel.ErrorCode.SuspendedAccount)
+ if (error.Code == TwitterErrorCode.InvalidToken ||
+ error.Code == TwitterErrorCode.SuspendedAccount)
{
Twitter.AccountState = MyCommon.ACCOUNT_STATE.Invalid;
}
}
}
- var res = new StringBuilder();
- res.Length = 0;
- res.Append("[");
- res.Append(line);
- res.Append("]");
-
if (isDm)
{
- CreateDirectMessagesFromJson(res.ToString(), MyCommon.WORKERTYPE.UserStream, false);
+ CreateDirectMessagesFromJson(line, MyCommon.WORKERTYPE.UserStream, false);
}
else
{
long dummy = 0;
- CreatePostsFromJson(res.ToString(), MyCommon.WORKERTYPE.Timeline, null, false, 0, ref dummy);
+ CreatePostsFromJson("[" + line + "]", MyCommon.WORKERTYPE.Timeline, null, false, 0, ref dummy);
}
}
catch(NullReferenceException)
private void CreateEventFromJson(string content)
{
- TwitterDataModel.EventData eventData = null;
+ TwitterStreamEvent eventData = null;
try
{
- eventData = MyCommon.CreateDataFromJson<TwitterDataModel.EventData>(content);
+ eventData = TwitterStreamEvent.ParseJson(content);
}
catch(SerializationException ex)
{
break;
case "favorite":
case "unfavorite":
- evt.Target = "@" + eventData.TargetObject.User.ScreenName + ":" + WebUtility.HtmlDecode(eventData.TargetObject.Text);
- evt.Id = eventData.TargetObject.Id;
+ var tweetEvent = TwitterStreamEvent<TwitterStatus>.ParseJson(content);
+ evt.Target = "@" + tweetEvent.TargetObject.User.ScreenName + ":" + WebUtility.HtmlDecode(tweetEvent.TargetObject.Text);
+ evt.Id = tweetEvent.TargetObject.Id;
if (AppendSettingDialog.Instance.IsRemoveSameEvent)
{
if (StoredEvent.Any(ev =>
return ev.Username == evt.Username && ev.Eventtype == evt.Eventtype && ev.Target == evt.Target;
})) return;
}
- if (TabInformations.GetInstance().ContainsKey(eventData.TargetObject.Id))
+ if (TabInformations.GetInstance().ContainsKey(tweetEvent.TargetObject.Id))
{
- var post = TabInformations.GetInstance()[eventData.TargetObject.Id];
+ var post = TabInformations.GetInstance()[tweetEvent.TargetObject.Id];
if (eventData.Event == "favorite")
{
if (evt.Username.ToLower().Equals(_uname))
case "list_updated":
case "list_user_subscribed":
case "list_user_unsubscribed":
- evt.Target = eventData.TargetObject.FullName;
+ var listEvent = TwitterStreamEvent<TwitterList>.ParseJson(content);
+ evt.Target = listEvent.TargetObject.FullName;
break;
case "block":
if (!TabInformations.GetInstance().BlockIds.Contains(eventData.Target.Id)) TabInformations.GetInstance().BlockIds.Add(eventData.Target.Id);
using System;
using System.Net;
+using OpenTween.Api;
namespace OpenTween
{
{
}
- public UserInfo(TwitterDataModel.User user)
+ public UserInfo(TwitterUser user)
{
this.Id = user.Id;
this.Name = WebUtility.HtmlDecode(user.Name).Trim();
using System.Web;
using System.IO;
using System.Net;
+using OpenTween.Api;
namespace OpenTween
{
public partial class UserInfoDialog : OTBaseForm
{
- private TwitterDataModel.User _displayUser;
- public TwitterDataModel.User DisplayUser
+ private TwitterUser _displayUser;
+ public TwitterUser DisplayUser
{
get { return this._displayUser; }
set
}
}
- private async Task SetRecentStatusAsync(TwitterDataModel.Status status)
+ private async Task SetRecentStatusAsync(TwitterStatus status)
{
var atlist = new List<string>();
{
var user = await Task.Run(() =>
{
- TwitterDataModel.User result = null;
+ TwitterUser result = null;
var err = this.Twitter.GetUserInfo(this._displayUser.ScreenName, ref result);
if (!string.IsNullOrEmpty(err))