private void AuthorizationWindow_FormClosing(object sender, FormClosingEventArgs e) { if (url != "") try { string[] accessTokenFirstSplit = url.Split('#'); if (accessTokenFirstSplit[1][0] == 'a') { string[] accessTokenSecondSplit = accessTokenFirstSplit[1].Split('&'); if (accessTokenSecondSplit[0][0] == 'a') { string[] accessTokenThirdSplit = accessTokenSecondSplit[0].Split('='); SettingsVk.Default.id = accessTokenSecondSplit[2].Split('=')[1]; SettingsVk.Default.token = accessTokenThirdSplit[1]; SettingsVk.Default.auth = true; //SettingsVk.Default.id } } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally {} string jfield = new ClassQueries().loadPage(String.Format("https://api.vk.com/method/users.get?user_ids={0}&fields=photo_200_orig&access_token={1}", SettingsVk.Default.id, SettingsVk.Default.token)); JToken jtoken = JToken.Parse(jfield); userList = jtoken["response"].Select(c => c.ToObject<User>()).ToList(); SettingsVk.Default.photo = userList[0].photo_200_orig; }
private void audioQuery() { try { string jfield = new ClassQueries().loadPage(String.Format("https://api.vk.com/method/audio.get?owner_id={0}&need_user=0&access_token={1}", SettingsVk.Default.id, SettingsVk.Default.token)); JToken jtoken = JToken.Parse(jfield); audioList = jtoken["response"].Children().Skip(1).Select(c => c.ToObject<Audio>()).ToList(); foreach (Audio audio in audioList) { listView1.Items.Add(audio.artist + " - " + audio.title); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }