using System;
using System.Runtime.Serialization;
using System.Collections.Generic;
+using OpenTween.Api;
namespace OpenTween.Api
{
}
[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 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 = "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 = "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 = "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 = "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 = "sender")] public TwitterUser Sender;
[DataMember(Name = "id_str")] public string IdStr;
- [DataMember(Name = "recipient")] public User Recipient;
+ [DataMember(Name = "recipient")] public TwitterUser Recipient;
[DataMember(Name = "recipient_screen_name")] public string RecipientScreenName;
[DataMember(Name = "recipient_id")] public Int64 RecipientId;
[DataMember(Name = "id")] public Int64 Id;
[DataContract]
public class EventData
{
- [DataMember(Name = "target")] public User Target;
+ [DataMember(Name = "target")] public TwitterUser 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;
+ [DataMember(Name = "source")] public TwitterUser Source;
}
[DataContract]
[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 = "user")] public TwitterUser User;
[DataMember(Name = "following")] public bool Following;
[DataMember(Name = "subscriber_count")] public int SubscriberCount;
[DataMember(Name = "description")] public string Description;
[DataContract]
public class Users
{
- [DataMember(Name = "users")] public User[] users;
+ [DataMember(Name = "users")] public TwitterUser[] users;
[DataMember(Name = "next_cursor")] public long NextCursor;
[DataMember(Name = "previous_cursor")] public long PreviousCursor;
}
--- /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 TwitterDataModel.Status 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);
+ }
+ }
+}
</ItemGroup>
<ItemGroup>
<Compile Include="Api\ApiLimit.cs" />
+ <Compile Include="Api\TwitterUser.cs" />
<Compile Include="Api\TwitterApiAccessLevel.cs" />
<Compile Include="Api\TwitterApiStatus.cs" />
<Compile Include="ApplicationEvents.cs">
{
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())
{
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)
{
}
}
- 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)
{
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)
{
post.IsFav = false;
//以下、ユーザー情報
- TwitterDataModel.User user;
+ TwitterUser user;
if (gType == MyCommon.WORKERTYPE.UserStream)
{
if (twCon.AuthenticatedUsername.Equals(message.Recipient.ScreenName, StringComparison.CurrentCultureIgnoreCase))
try
{
var users = MyCommon.CreateDataFromJson<TwitterDataModel.Users>(content);
- Array.ForEach<TwitterDataModel.User>(
+ Array.ForEach<TwitterUser>(
users.users,
- new Action<TwitterDataModel.User>(u => lists.Add(new UserInfo(u))));
+ u => lists.Add(new UserInfo(u)));
cursor = users.NextCursor;
return "";
}
try
{
- var u = MyCommon.CreateDataFromJson<TwitterDataModel.User>(content);
+ var u = TwitterUser.ParseJson(content);
value = true;
return "";
}
{
}
- public UserInfo(TwitterDataModel.User user)
+ public UserInfo(TwitterUser user)
{
this.Id = user.Id;
this.Name = WebUtility.HtmlDecode(user.Name).Trim();
{
public partial class UserInfoDialog : OTBaseForm
{
- private TwitterDataModel.User _displayUser;
- public TwitterDataModel.User DisplayUser
+ private TwitterUser _displayUser;
+ public TwitterUser DisplayUser
{
get { return this._displayUser; }
set
{
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))