private void GetAuthInfo(string code) { VkontakteAccessToken accessTokenInfo = GetAccessTokenInfo(code); VkontakteUserProfile userProfile = GetUserInfo(accessTokenInfo.user_id, accessTokenInfo.access_token); Response.Write("FirtName:" + userProfile.response[0].first_name); Response.Write("Sex:" + userProfile.response[0].sex); Response.Write("City:" + userProfile.response[0].city); Response.Write("Photo:" + userProfile.response[0].photo); }
VkontakteUserProfile GetUserInfo(string user_id, string access_token) { string getUserProfileUrl = string.Format("https://api.vkontakte.ru/method/getProfiles?uid={0}&fields={1}&access_token={2}", user_id, "first_name,last_name,nickname,sex,bdate,city,country,photo", access_token); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(getUserProfileUrl); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Encoding enc = Encoding.GetEncoding("utf-8"); StreamReader configStream = new StreamReader(response.GetResponseStream(), enc); string profileJson = configStream.ReadToEnd(); JavaScriptSerializer serializer = new JavaScriptSerializer(); VkontakteUserProfile userProfile = serializer.Deserialize <VkontakteUserProfile>(profileJson); return(userProfile); }