private void ShowActiveAccounts() { AccountList.Items.Clear(); List <long> Ids = new List <long>(); foreach (var account in GetSavedAuthData()) { long lgp = long.Parse(account["ID"].ToString()); Ids.Add(lgp); Debug.WriteLine(lgp); AccountList.Items.Add(new UserData { Id = lgp, Token = account["Token"].ToString(), Name = account["Name"].ToString(), }); } var api = new VkNet.VkApi(); api.Authorize(new VkNet.Model.ApiAuthParams() { AccessToken = "4b0168fd4b0168fd4b0168fd8f4b676c6744b014b0168fd1093d8fdf1e3c0017422a04c" }); var data = api.Users.Get(Ids, ProfileFields.Photo50); for (int i = 0; i < AccountList.Items.Count; i++) { if (data[i].Photo50 != null) { ((UserData)AccountList.Items[i]).AvatarUrl = data[i].Photo50.AbsoluteUri; } } Ids.Clear(); }
private void Button_Click(object sender, RoutedEventArgs e) { try { uint appIDD = 7099217; Settings settings = Settings.All; vkApi.Authorize(new ApiAuthParams { ApplicationId = appIDD, Login = Login.Text, Password = PasswordBox.Password, Settings = settings, });; } catch (Exception) { MessageBox.Show("Введены неверные данные", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } VkApi = vkApi; Window1 form1 = new Window1(); form1.Show(); Visibility = Visibility.Hidden; GC.Collect(); }
public HomeController() { VkApi.VkApi api = new VkApi.VkApi((int)_applicationId, "messages"); //api.Authorization("+79687361740", ",eheyler"); //Моя авторизация перестала работать VkNet.VkApi net = new VkNet.VkApi(); net.Authorize(new VkNet.ApiAuthParams //Авторизация работает, но апи слабое { Login = "******", ApplicationId = _applicationId, Password = "******", Settings = Settings.All }); VkApi.VkApi.Token = net.Token; //А токен пригодится :) int membersCount = GroupService.GetMembersCount(27794994); for (int i = 0; membersCount > 0; membersCount -= 100, i++) { int count = membersCount >= 100 ? 100 : membersCount; IEnumerable <User> currentUsers = GroupService.GetMembers(27794994, (0 + i * 100), count, 10); currentUsers = currentUsers.Where(u => u.sex == Sex.Female && (u.relation != Relation.HaveFriend || u.relation != Relation.Engaged || u.relation != Relation.Married || u.relation != Relation.Love) && u.deactivated == null); users.AddRange(currentUsers); Console.WriteLine($"Добавлено {currentUsers.Count()} пользователей. Осталось {membersCount} пользователей. Осталось {TimeSpan.FromSeconds(membersCount / 200)}"); } }
private void AccountList_SelectionChanged(object sender, SelectionChangedEventArgs e) { VkNet.VkApi api = new VkNet.VkApi(); var item = (UserData)AccountList.SelectedItem; api.Authorize(new VkNet.Model.ApiAuthParams { AccessToken = item.Token, UserId = (long)item.Id, }); try { api.Account.GetInfo(); if (api.IsAuthorized) { Tools.VkApi = api; } } catch (VkNet.Exception.UserAuthorizationFailException ex) { PreviewErrorBorder = this.AccountListPanelBorder; PreviewErrorBorder.Visibility = Visibility.Collapsed; this.AuthErrorBorder.Visibility = Visibility.Visible; this.AuthErrorCodeTextRun.Text = "Код:" + ex.ErrorCode; this.AuthErrorTextRun.Text = ex.Message; } }
static void Main(string[] args) { VkApi.VkApi api = new VkApi.VkApi((int)_applicationId, "messages"); //api.Authorization("+79687361740", ",eheyler"); //Моя авторизация перестала работать VkNet.VkApi net = new VkNet.VkApi(); net.Authorize(new VkNet.ApiAuthParams //Авторизация работает, но апи слабое { Login = "******", ApplicationId = _applicationId, Password = "******", Settings = Settings.All }); VkApi.VkApi.Token = net.Token; //А токен пригодится :) int membersCount = GroupService.GetMembersCount(27794994); List <User> users = new List <User>(); for (int i = 0; membersCount > 0; membersCount -= 100, i++) { int count = membersCount >= 100 ? 100 : membersCount; IEnumerable <User> currentUsers = GroupService.GetMembers(27794994, (0 + i * 100), count, 10); currentUsers = currentUsers.Where(u => u.sex == Sex.Female && (u.relation != Relation.HaveFriend || u.relation != Relation.Engaged || u.relation != Relation.Married || u.relation != Relation.Love) && u.deactivated == null); users.AddRange(currentUsers); Console.WriteLine($"Добавлено {currentUsers.Count()} пользователей. Осталось {membersCount} пользователей. Осталось {TimeSpan.FromSeconds(membersCount/200)}"); } //IEnumerable<Item> UnreadMessages = messages.Where(message => message.ReadState == 1 && message.Attachments != null && message.Attachments.Where(attachment => attachment.Market != null).Count() != 0); //foreach (var message in UnreadMessages) //{ //} Console.ReadKey(); }
public static void login() { ulong appId = 6236745; string email = "79166054162"; string password = "******"; VkNet.Enums.Filters.Settings settings = VkNet.Enums.Filters.Settings.All; api = new VkNet.VkApi(); api.Authorize(new VkNet.ApiAuthParams { ApplicationId = appId, Login = email, Password = password, Settings = settings }); }
private static void SetVkApiInstrumentProfile(object sender, KeyValuePair <string, string> e) { api = new VkNet.VkApi(); api.Authorize(new ApiAuthParams { ApplicationId = 6394527, Login = e.Key, Password = e.Value, Settings = Settings.All, TwoFactorAuthorization = () => { Console.WriteLine("Enter Code:"); return(Console.ReadLine()); } }); }
private static void SetVkApiInstrumentProfile(object sender, KeyValuePair <string, string> e) { api = new VkNet.VkApi(); //6884639 api.Authorize(new ApiAuthParams { ApplicationId = 6884639, Login = "******", Password = "******", // Settings = Settings.Friends, TwoFactorAuthorization = () => { Console.WriteLine("Enter Code:"); return(Console.ReadLine()); } }); }
static void Main(string[] args) { Dictionary <string, int> words = new Dictionary <string, int>(); Dictionary <string, string> keys = new Dictionary <string, string>(); VkNet.VkApi vkApi = new VkNet.VkApi(); vkApi.Authorize(new ApiAuthParams { ApplicationId = 000000, Login = "******", Password = "******", Settings = VkNet.Enums.Filters.Settings.All }); Random r = new Random(); List <User> users = new List <User>(); List <long> aaa = new List <long>(); Test yyyy = Test.Load("msg_sc.json"); Regex rr = new Regex("\\)+"); // yyyy.i -= 101032;//Хомяки //ulong hor = (ulong)vkApi.Messages.GetHistory(new VkNet.Model.RequestParams.MessagesGetHistoryParams { PeerId = 2000000107 }).Messages[0].OutRead; List <Message> msg = new List <Message>(); MessageGetHistoryObject aa = new MessageGetHistoryObject(); while (yyyy.i < 50980) { try { int y = r.Next(21); aa = vkApi.Messages.GetHistory(new VkNet.Model.RequestParams.MessagesGetHistoryParams { PeerId = 2000000168, //для Аколитской флудилки цифра - 148, для студсовета - 168 Count = 180 + y, Offset = yyyy.i, Reversed = true }); yyyy.i += 180 + y; } catch (Exception e) { yyyy.i += 200; continue; } Thread.Sleep(250 + r.Next(750)); msg.AddRange(aa.Messages); } foreach (Message s in msg) { //int day = (((DateTime)s.Date).Year - 2016) * 365 + ((DateTime)s.Date).DayOfYear; if (yyyy.users.ContainsKey((long)s.FromId)) { yyyy.users[(long)s.FromId]++; } else { yyyy.users.Add((long)s.FromId, 1); } if (s.Emoji.HasValue || rr.Match(s.Text).Value == s.Text) { if (yyyy.smiles.ContainsKey((long)s.FromId)) { yyyy.smiles[(long)s.FromId]++; } else { yyyy.smiles.Add((long)s.FromId, 1); } } if (s.Attachments.Count > 0) { if (yyyy.pictures.ContainsKey((long)s.FromId)) { yyyy.pictures[(long)s.FromId]++; } else { yyyy.pictures.Add((long)s.FromId, 1); } } if (s.Attachments.Count > 0 || s.Emoji.HasValue || rr.Match(s.Text).Value == s.Text) { if (yyyy.flood.ContainsKey((long)s.FromId)) { yyyy.flood[(long)s.FromId]++; } else { yyyy.flood.Add((long)s.FromId, 1); } } /*if (yyyy.dates.ContainsKey(day)) * yyyy.dates[day]++; * else yyyy.dates.Add(day, 1);*/ } List <long> a = new List <long>(); foreach (var s in yyyy.users) { a.Add(s.Key); } var gusers = vkApi.Users.Get(a); var lusers = gusers.OrderBy(x => { return(yyyy.users[x.Id]); } ).Reverse(); int tst = 0; int flood = 0; // yyyy.i += 101032; foreach (var s in lusers) { string t = s.FirstName + " " + s.LastName; tst += yyyy.users[s.Id]; if (!yyyy.pictures.ContainsKey(s.Id)) { yyyy.pictures.Add(s.Id, 0); } if (!yyyy.smiles.ContainsKey(s.Id)) { yyyy.smiles.Add(s.Id, 0); } if (!yyyy.flood.ContainsKey(s.Id)) { yyyy.flood.Add(s.Id, 0); } flood += yyyy.flood[s.Id]; Console.WriteLine(t + " нафлудил: " + yyyy.users[s.Id].ToString() + " из них " + yyyy.pictures[s.Id].ToString() + " с картинками, и " + yyyy.smiles[s.Id].ToString() + " со смайлами"); } //Console.WriteLine("Сергей написал " + (ser + seroff).ToString() + " сообщений только из скобочек, из них " + seroff + " не из трех. Злых (><) смайлов было "+serang+". Эл написал "+l+" косящихся глаз."); yyyy.Save("msg_sc.json"); /*using (StreamWriter sw = new StreamWriter("int.txt", false)) * { * foreach (var t in yyyy.dates) * { * sw.Write(t.Value.ToString() + " "); * } * }*/ Console.ReadLine(); }
public VkApi(string token) { api.Authorize(new ApiAuthParams { AccessToken = token }); }