public void GetInfo(string[] uids, string[] fields, bool emptyPictures, OKGetInfoCallback callback) { // Number of requests needed to obtain data for all required users, API limited by 100/request. int requestCounter = (uids.Length / 100) + ((uids.Length % 100 > 0) ? 1 : 0); HTTP.Response[] responseList = new Response[requestCounter]; int responseCounter = 0; int responseUserCount = 0; for (int j = 0; j < requestCounter; j++) { int requestIndex = j; // Find the remaining number of uids to send, maximum 100, and put these uids in list. int maxCount = Math.Min(100, uids.Length - j * 100); string[] requestUids = uids.Skip(j * 100).Take(maxCount).ToArray(); Api(OKMethod.Users.getInfo, new Dictionary <string, string> { { "uids", string.Join(",", requestUids) }, { "fields", string.Join(",", fields) }, { "emptyPictures", emptyPictures.ToString() } }, delegate(HTTP.Response response) { string error = response.Error; if (!string.IsNullOrEmpty(error)) { // In case of error, return a 0-element list callback(new OKUserInfo[0]); } else { // Store response responseList[requestIndex] = response; responseCounter++; // Count user response Array objects. responseUserCount += response.Array.Count; // Process data on last response received if (responseCounter == requestCounter) { OKUserInfo[] userInfos = new OKUserInfo[responseUserCount]; int responseIndex = 0; // Iterate all response objects and save all user response Array objects. for (int k = 0; k < requestCounter; k++) { ArrayList users = responseList[k].Array; for (int i = 0; i < users.Count; i++) { userInfos[responseIndex] = new OKUserInfo((Hashtable)users[i]); responseIndex++; } } callback(userInfos); } } } ); } }
public void GetInfo(string[] uids, string[] fields, bool emptyPictures, OKGetInfoCallback callback) { Api(OKMethod.Users.getInfo, new Dictionary <string, string> { { "uids", string.Join(",", uids) }, { "fields", string.Join(",", fields) }, { "emptyPictures", emptyPictures.ToString() } }, delegate(HTTP.Response response) { ArrayList users = response.Array; OKUserInfo[] userInfos = new OKUserInfo[users.Count]; for (int i = 0; i < users.Count; i++) { userInfos[i] = new OKUserInfo((Hashtable)users[i]); } callback(userInfos); } ); }
/** * This is an API request wrapper that automatically splits requests into 100 uid chunks, based on API limitations at the time of implementation. * This API only works when there is a session, can return an empty OKUserInfo[] list in case of an error. */ public static void GetInfo(OKGetInfoCallback callback, string[] uids, string[] fields, bool emptyPictures = false) { OdnoklassnikiImpl.GetInfo(uids, fields, emptyPictures, callback); }
public void GetInfo(string[] uids, string[] fields, bool emptyPictures, OKGetInfoCallback callback) { // Number of requests needed to obtain data for all required users, API limited by 100/request. int requestCounter = (uids.Length / 100) + ((uids.Length % 100 > 0) ? 1 : 0); HTTP.Response[] responseList = new Response[requestCounter]; int responseCounter = 0; int responseUserCount = 0; for (int j = 0; j < requestCounter; j++) { int requestIndex = j; // Find the remaining number of uids to send, maximum 100, and put these uids in list. int maxCount = Math.Min(100, uids.Length - j * 100); string[] requestUids = uids.Skip(j * 100).Take(maxCount).ToArray(); Api(OKMethod.Users.getInfo, new Dictionary<string, string> { {"uids", string.Join(",", requestUids)}, {"fields", string.Join(",", fields)}, {"emptyPictures", emptyPictures.ToString()} }, delegate (HTTP.Response response) { string error = response.Error; if (!string.IsNullOrEmpty(error)) { // In case of error, return a 0-element list callback(new OKUserInfo[0]); } else { // Store response responseList[requestIndex] = response; responseCounter++; // Count user response Array objects. responseUserCount += response.Array.Count; // Process data on last response received if (responseCounter == requestCounter) { OKUserInfo[] userInfos = new OKUserInfo[responseUserCount]; int responseIndex = 0; // Iterate all response objects and save all user response Array objects. for (int k = 0; k < requestCounter; k++) { ArrayList users = responseList[k].Array; for (int i = 0; i < users.Count; i++) { userInfos[responseIndex] = new OKUserInfo((Hashtable) users[i]); responseIndex++; } } callback(userInfos); } } } ); } }