/// <summary> /// Formatting target uri and request api /// </summary> /// <remarks> /// For twitter api version 1 /// </remarks> private static XDocument RequestAPIv1(this CredentialProvider provider, string partial, CredentialProvider.RequestMethod method, IEnumerable<KeyValuePair<string, string>> param) { var target = TwitterUri + (partial.EndsWith("/") ? partial.Substring(1) : partial); return provider.RequestAPI(target, method, param); }
/// <summary> /// Get status /// </summary> private static TwitterStatus GetStatus(this CredentialProvider provider, string partialUriFormat, CredentialProvider.RequestMethod method, long id) { string partialUri = string.Format(partialUriFormat, id); var doc = provider.RequestAPIv1(partialUri, method, null); if (doc == null) return null; return TwitterStatus.CreateByNode(doc.Element("status")); }
/// <summary> /// Get user with full params /// </summary> private static TwitterUser GetUser(this CredentialProvider provider, string partialUri, CredentialProvider.RequestMethod method, long? userId, string screenName) { List<KeyValuePair<string, string>> para = new List<KeyValuePair<string, string>>(); if (userId != null) { para.Add(new KeyValuePair<string,string>("user_id", userId.ToString())); } if (screenName != null) { para.Add(new KeyValuePair<string,string>("screen_name", screenName)); } var doc = provider.RequestAPIv1(partialUri, method, para); if (doc == null) return null; return TwitterUser.CreateByNode(doc.Element("user")); }
/// <summary> /// Get status /// </summary> private static TwitterStatus GetStatus(this CredentialProvider provider, string partialUriFormat, CredentialProvider.RequestMethod method, long id) { string partialUri = string.Format(partialUriFormat, id); var doc = provider.RequestAPI(partialUri, method, null); if (doc == null) return null; TwitterStatus s = TwitterStatus.CreateByNode(doc.Element("root")); if (s == null) throw new Exceptions.TwitterXmlParseException("status can't read."); return s; }