/// <summary> /// Get a List of Friends Ids by using the Current Token /// </summary> /// <param name="token">Token to operate the query</param> /// <param name="createUserIdsList">Whether this method will fill the Friends list</param> /// <param name="cursor">Current Page of the query</param> /// <returns>List of Friends Id</returns> public List <long> GetFriendsIds(IToken token, bool createUserIdsList = false, long cursor = 0) { token = GetQueryToken(token); if (token == null) { return(null); } if (cursor == 0) { FriendIds = new List <long>(); Friends = new List <IUser>(); } DynamicResponseDelegate del = delegate(dynamic responseObject, long previous_cursor, long next_cursor) { foreach (var friend_id in responseObject["ids"]) { FriendIds.Add((long)friend_id); if (createUserIdsList) { Friends.Add(new User((long)friend_id) { ObjectToken = _shareTokenWithChild ? this._token : null, }); } } }; if (Id != null) { token.ExecuteCursorQuery(String.Format(Resources.User_GetFriendsIdsFromId, Id), del); } else { if (_screen_name != null) { token.ExecuteCursorQuery(String.Format(Resources.User_GetFriendsIdsFromScreenName, ScreenName), del); } } return(FriendIds); }
/// <summary> /// Function that execute cursor query and send information for each query executed /// </summary> /// <param name="token"></param> static void ExecuteCursorQuery(IToken token) { // The delegate is a function that will be called for each cursor DynamicResponseDelegate del = delegate(dynamic jsonResponse, long previous_cursor, long next_cursor) { Console.WriteLine(previous_cursor + " -> " + next_cursor + " : " + jsonResponse.Count); }; token.ExecuteCursorQuery("https://api.twitter.com/1/friends/ids.json?user_id=700562792", del); }
/// <summary> /// Get the followers of a User by using the specified Token /// </summary> /// <param name="token">Token to operate a query</param> /// <param name="createFollowerList">Whether this method will fill the Follower list</param> /// <param name="cursor">Current Page of the query</param> /// <param name="maxFollowers">Max number of users</param> /// <returns>List of Followers Id</returns> public List <long> GetFollowerIds(IToken token, bool createFollowerList = false, long cursor = 0, int maxFollowers = Int32.MaxValue) { token = GetQueryToken(token); if (token == null) { return(null); } if (cursor == 0) { FollowerIds = new List <long>(); Followers = new List <IUser>(); } string query = Resources.User_GetFollowers; if (!AddUserInformationInQuery(ref query)) { return(null); } DynamicResponseDelegate del = delegate(Dictionary <string, object> responseObject, long previousCursor, long nextCursor) { var userIds = (responseObject["ids"] as IEnumerable <object>) != null ? (responseObject["ids"] as IEnumerable <object>).ToList() : null; if (userIds != null) { foreach (var followerId in userIds) { FollowerIds.Add(Int64.Parse(followerId.ToString())); if (createFollowerList) { Followers.Add(new User(Int64.Parse(followerId.ToString())) { ObjectToken = _shareTokenWithChild ? _token : null, }); } } return(userIds.Count()); } return(0); }; token.ExecuteCursorQuery(query, del); return(FollowerIds); }
/// <summary> /// Get the followers of a User by using the specified Token /// </summary> /// <param name="token">Token to operate a query</param> /// <param name="createFollowerList">Whether this method will fill the Follower list</param> /// <param name="cursor">Current Page of the query</param> /// <returns>List of Followers Id</returns> public List <long> GetFollowers(IToken token, bool createFollowerList = false, long cursor = 0) { token = GetQueryToken(token); if (token == null) { return(null); } if (cursor == 0) { FollowerIds = new List <long>(); Followers = new List <IUser>(); } string query = Resources.User_GetFollowers; AddUserInformationInQuery(ref query); DynamicResponseDelegate del = delegate(dynamic responseObject, long previous_cursor, long next_cursor) { foreach (var follower_id in responseObject["ids"]) { FollowerIds.Add((long)follower_id); if (createFollowerList) { Followers.Add(new User((long)follower_id) { ObjectToken = _shareTokenWithChild ? this._token : null, }); } } }; token.ExecuteCursorQuery(query, del); return(FollowerIds); }