public static VkProfile FromJson(JToken json) { VkProfile vkProfile = new VkProfile(); vkProfile.Id = json["uid"].Value <long>(); vkProfile.FirstName = json["first_name"].Value <string>(); vkProfile.LastName = json["last_name"].Value <string>(); if (json["photo"] != null) { vkProfile.Photo = new Uri(json["photo"].Value <string>()); } if (json["photo_medium"] != null) { vkProfile.PhotoMedium = new Uri(json["photo_medium"].Value <string>()); } if (json["photo_big"] != null) { vkProfile.PhotoBig = new Uri(json["photo_big"].Value <string>()); } if (json["online"] != null) { vkProfile.IsOnline = json["online"].Value <bool>(); } if (json["university_name"] != null) { vkProfile.Education = json["university_name"].Value <string>(); } if (json["bdate"] != null) { vkProfile.Birthday = json["bdate"].Value <string>(); } if (json["country"] != null) { vkProfile.Country = json["country"].Value <string>(); } if (json["city"] != null) { vkProfile.City = json["city"].Value <string>(); } return(vkProfile); }
public async Task <IEnumerable <VkProfile> > Get(IEnumerable <string> uids, string fields, string nameCase) { Dictionary <string, string> dictionary = new Dictionary <string, string>(); if (uids != null) { dictionary.Add("uids", string.Join(",", uids)); } if (!string.IsNullOrWhiteSpace(fields)) { dictionary.Add("fields", fields); } if (!string.IsNullOrWhiteSpace(nameCase)) { dictionary.Add("name_case", nameCase); } dictionary.Add("access_token", Vkontakte.Instance.AccessToken.Token); JObject jObject = await new VkRequest(new Uri("https://api.vk.com/method/users.get"), dictionary, "GET").Execute(); VkErrorProcessor.ProcessError(jObject); IEnumerable <VkProfile> result; if (jObject["response"].HasValues) { result = Enumerable.Select <JToken, VkProfile>(jObject["response"], (JToken u) => VkProfile.FromJson(u)); } else { result = null; } return(result); }