--- /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 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;
}
[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 TwitterUser 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 TwitterEntities 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 TwitterUser 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 TwitterEntities Entities;
- }
-
- [DataContract]
- public class TargetObject : Status
+ public class TargetObject : TwitterStatus
{
[DataMember(Name = "mode")] public string Mode;
[DataMember(Name = "description")] public string Description;
[DataMember(Name = "annotations")] public Annotations Annotations;
[DataMember(Name = "kind")] public string Kind;
[DataMember(Name = "score")] public double Score;
- [DataMember(Name = "value")] public Status Status;
+ [DataMember(Name = "value")] public TwitterStatus Status;
}
[DataContract]
[DataContract]
public class SearchResult
{
- [DataMember(Name = "statuses")] public List<Status> Statuses;
+ [DataMember(Name = "statuses")] public List<TwitterStatus> Statuses;
[DataMember(Name = "search_metadata")] public SearchMetadata SearchMetadata;
}
--- /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 TwitterDataModel.Place 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);
+ }
+ }
+}
public bool ShowAllInlineMedia { get; set; }
[DataMember(Name = "status", IsRequired = false)]
- public TwitterDataModel.Status Status { get; set; } // Nullable
+ public TwitterStatus Status { get; set; } // Nullable
[DataMember(Name = "statuses_count")]
public int StatusesCount { get; set; }
</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\TwitterList.cs" />
+ <Compile Include="Api\TwitterStatus.cs" />
<Compile Include="Api\TwitterUser.cs" />
<Compile Include="Api\TwitterApiAccessLevel.cs" />
<Compile Include="Api\TwitterApiStatus.cs" />
}
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.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)
{
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 "";
}
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();
TwitterEntities entities;
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)
{
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)
{
}
}
- private async Task SetRecentStatusAsync(TwitterDataModel.Status status)
+ private async Task SetRecentStatusAsync(TwitterStatus status)
{
var atlist = new List<string>();