示例#1
0
		/// <summary>
		/// Document: http://dev.twitter.com/doc/get/users/show
		/// Supported formats: json, xml
		/// Supported request methods: GET
		/// Requires Authentication: false
		/// Rate Limited: true
		/// Required Parameters: user_id, screen_name
		/// </summary>
		/// <param name="extension">jsonに対応</param>
		/// <param name="options">Documentを参照してください</param>
		/// <returns></returns>
		public static User Show(Format extension, params string[] options) {
			string postData = string.Empty;
			string query = TwitterUtility.GetQuery(oAuthTwitter.Method.GET, ref postData, ApiSelector.UsersShow, extension, options);
			string response = ModelUtility.DownloadContext(query);

			User user;
			switch (extension) {
				case Format.Xml:
					var xmlDoc = new XmlDocument();
					xmlDoc.LoadXml(response);
					XmlNode node = xmlDoc.SelectSingleNode("user");
					user = new User(node);
					break;
				case Format.Json:
				default:
					throw new NotImplementedException();
			}
			return user;
		}
示例#2
0
		public Status(XmlNode node, UserType userType) {
			string localUserName = null;
			if (userType == UserType.DirectMessage) {
				localUserName = "******";
			} else if (userType == UserType.Others) {
				localUserName = "******";
			}

			User = new User(node.SelectSingleNode(localUserName));
			if (node["created_at"] != null) {
				CreatedAt = DateTime.ParseExact(
					node["created_at"].InnerText,
					"ddd MMM dd HH':'mm':'ss zzzz yyyy",
					System.Globalization.DateTimeFormatInfo.InvariantInfo,
					System.Globalization.DateTimeStyles.None
				).ToString(dateFormat);
			}
			if (node["id"] != null) {
				Id = node["id"].InnerText;
			}
			if (node["source"] != null) {
				Source = FormatSource(node["source"].InnerText);
			}
			if (node["text"] != null) {
				Text = node["text"].InnerText;
			}
			if (node["favorited"] != null) {
				Favorited = node["favorited"].InnerText == "true";
			}
			if (node["in_reply_to_status_id"] != null) {
				InReplyToStatusId = node["in_reply_to_status_id"].InnerText;
			}
		}
示例#3
0
		public Status(SyndicationItem item) {
			string[] names = item.Authors[0].Name.Replace(" ", "").Replace('(', '/').TrimEnd(')').Split('/');
			User = new User {
				ScreenName = names[0],
				Name = names[1],
				ProfileImageUrl = item.Links[1].Uri.ToString(),
			};

			CreatedAt = item.PublishDate.LocalDateTime.ToString(dateFormat);
			Id = item.Id;
			Source = FormatSource(item.ElementExtensions.ReadElementExtensions<string>("source", "http://api.twitter.com/")[0]);
			Text = item.Title.Text;
		}
示例#4
0
		public Status(Dictionary<string, object> status, CreatedAtFormatType formatType) {
			if (status.ContainsKey("user")) {
				var user = status["user"] as Dictionary<string, object>;
				if (user != null) {
					User = new User(user);
				}
			}
			if (status.ContainsKey("created_at")) {
				string createdAtFormt = null;
				if (formatType == CreatedAtFormatType.Search) {
					createdAtFormt = "ddd',' dd MMM yyyy HH':'mm':'ss zzzz";
				} else if (formatType == CreatedAtFormatType.Streaming) {
					createdAtFormt = "ddd MMM dd HH':'mm':'ss zzzz yyyy";
				}

				CreatedAt = DateTime.ParseExact(
					status["created_at"] as string,
					createdAtFormt,
					System.Globalization.DateTimeFormatInfo.InvariantInfo,
					System.Globalization.DateTimeStyles.None
				).ToString(dateFormat);
			}
			if (status.ContainsKey("id_str")) {
				Id = status["id_str"] as string;
			}
			if (status.ContainsKey("source")) {
				Source = FormatSource(status["source"] as string);
			}
			if (status.ContainsKey("text")) {
				Text = status["text"] as string;
			}
			if (status.ContainsKey("in_reply_to_status_id")) {
				var id = status["in_reply_to_status_id"];
				if (id != null) {
					InReplyToStatusId = id.ToString();
				}
			}
		}