Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 146 lines (142 sloc) 4.72 KB
Index: TwitterService.cs
===================================================================
--- TwitterService.cs (revision 675)
+++ TwitterService.cs (working copy)
@@ -302,6 +302,7 @@
return GetFriends(1);
}
+
/// <summary>
/// friendsを取得します。
/// </summary>
@@ -310,27 +311,31 @@
public User[] GetFriends(Int32 maxPage)
{
List<User> usersList = new List<User>();
- Int32 page = 0;
+ Int64 cursor = -1;
+ Int32 count = 0;
return ExecuteRequest<User[]>(() =>
{
- while (page++ != maxPage)
+ while (count++ != maxPage)
{
- String responseBody = GET(String.Format("/statuses/friends.xml?page={0}&lite=true", page));
+ String responseBody = GET(String.Format("/statuses/friends.xml?cursor={0}", cursor));
if (NilClasses.CanDeserialize(responseBody))
{
return usersList.ToArray();
}
else
{
- Users users = Users.Serializer.Deserialize(new StringReader(responseBody)) as Users;
- if (users == null || users.User == null || users.User.Length == 0)
+ Users_list users_list = Users_list.Serializer.Deserialize(new StringReader(responseBody)) as Users_list;
+ Users users = users_list.users;
+ if (users == null || users.User == null || users.User.Length == 0 )
{
return usersList.ToArray();
}
else
{
usersList.AddRange(users.User);
- if (users.User.Length < 100)
+ cursor = users_list.Next_cursor;
+
+ if (users_list.Next_cursor == 0)
break;
}
}
@@ -571,6 +576,31 @@
}
/// <summary>
+ /// ステータスIDを指定して発言を取得する
+ /// </summary>
+ /// <param name="statusID">取得対象のステータスID</param>
+ /// <returns>対象の発言</returns>
+ public Status GetPostByStatusId(string statusID)
+ {
+ return ExecuteRequest<Status>(() =>
+ {
+ string responseBody = GET(string.Format("/statuses/show/{0}.xml", statusID));
+ Status status;
+ if (NilClasses.CanDeserialize(responseBody))
+ {
+ status = null;
+ }
+ else
+ {
+ status = Status.Serializer.Deserialize(new StringReader(responseBody)) as Status;
+ }
+
+ return status;
+ });
+ }
+
+
+ /// <summary>
/// 指定したユーザの favorites を取得します。
/// </summary>
/// <param name="screenName">スクリーンネーム</param>
@@ -1759,6 +1789,43 @@
}
/// <summary>
+ /// Cursor情報とUsersのセットを格納します。
+ /// </summary>
+ [XmlType("users_list")]
+ public class Users_list
+ {
+ [XmlElement("users")]
+ public Users users;
+
+ [XmlElement("next_cursor")]
+ public Int64 Next_cursor;
+
+ [XmlElement("previous_cursor")]
+ public Int64 Previous_cursor;
+
+ private static Object _syncObject = new object();
+ private static XmlSerializer _serializer = null;
+ static Users_list()
+ {
+ lock (_syncObject)
+ {
+ if (_serializer == null)
+ {
+ _serializer = new XmlSerializer(typeof(Users_list));
+ }
+ }
+ }
+ public static XmlSerializer Serializer
+ {
+ get
+ {
+ return _serializer;
+ }
+ }
+
+ }
+
+ /// <summary>
/// Userのセットを格納します。
/// </summary>
[XmlType("users")]
@@ -1883,8 +1950,17 @@
private String _text;
[XmlIgnore]
private DateTime _createdAt;
-
+
[XmlIgnore]
+ public String GetInReplyToStatusId
+ {
+ get
+ {
+ return InReplyToStatusId;
+ }
+ }
+
+ [XmlIgnore]
public String Text
{
get