/// <summary> /// Возвращает список идентификаторов друзей пользователя или расширенную /// информацию о друзьях пользователя (при /// использовании параметра fields). /// </summary> /// <param name="params"> Входные параметры выборки. </param> /// <param name="skipAuthorization"> Если <c> true </c>, то пропустить авторизацию </param> /// <returns> /// После успешного выполнения возвращает список идентификаторов (id) друзей /// пользователя, если параметр fields не /// использовался. /// При использовании параметра fields возвращает список объектов пользователей, /// но не более 5000. /// </returns> /// <remarks> /// Страница документации ВКонтакте http://vk.com/dev/friends.get /// </remarks> public VkCollection <User> Get(FriendsGetParams @params, bool skipAuthorization = false) { return(_vk.Call(methodName: "friends.get", parameters: @params, skipAuthorization: skipAuthorization) .ToVkCollectionOf(selector: x => @params.Fields != null ? x : new User { Id = x })); }
public void Run() { var friendsGetParam = new FriendsGetParams(); friendsGetParam.Fields = ProfileFields.Nickname; var friends = _vk.Friends.Get(friendsGetParam); var messagesSendParams = new MessagesSendParams(); messagesSendParams.Message = "Bot is ready to serve to you!"; _Log.Invoke("Friends:"); foreach (User friend in friends) { _Log.Invoke($"\t{friend.FirstName} {friend.LastName}"); messagesSendParams.UserId = friend.Id; _vk.Messages.Send(messagesSendParams); _vk.Messages.DeleteDialog(friend.Id); } _Log.Invoke("===================================="); MainLoop(); messagesSendParams.Message = "Bot completed its work..."; friends = _vk.Friends.Get(friendsGetParam); foreach (User friend in friends) { messagesSendParams.UserId = friend.Id; _vk.Messages.Send(messagesSendParams); _vk.Messages.DeleteDialog(friend.Id); } _Log.Invoke("===================================="); }
public void Get_friends() // Getting friend list { int Count = 0; var query = new FriendsGetParams { UserId = api.UserId, Fields = ProfileFields.All }; // Getting needed fields var users = api.Friends.Get(query).OrderByDescending(x => x.Online); // Friends sort foreach (var x in users) { SolidColorBrush status; if (x.Online == true) // Setting status color { status = x.OnlineMobile == true ? new SolidColorBrush(Colors.CornflowerBlue) : new SolidColorBrush(Colors.DarkGreen); } else { status = new SolidColorBrush(Colors.Red); Count++; } Friend fr = new Friend(x.FirstName, x.LastName, new BitmapImage(x.Photo50), status, x.Id); // Get instances of friend's class Friends.Add(fr); //adding it to list of all friends } TotalFriends = Friends.Count; OnlineFriends = Friends.Count - Count; }
public ReadOnlyCollection <User> Get(FriendsGetParams @params) { var response = _vk.Call("friends.get", @params); return(response.ToReadOnlyCollectionOf <User>(x => @params.Fields != null ? x : new User { Id = x })); }
public VkCollection <User> GetFriends(long?userId = null) { var friendsGetParams = new FriendsGetParams { UserId = userId, Fields = ProfileFields.FirstName | ProfileFields.PhotoMaxOrig | ProfileFields.LastName | ProfileFields.Blacklisted | ProfileFields.Photo50 }; return(_vkApi.Friends.Get(friendsGetParams)); }
private void GetFriends() { GetPeopleList.Add((int)App.AuthPublic.UserId, "Моя музыка"); var _friends = new FriendsGetParams(); _friends.Fields = ProfileFields.FirstName | ProfileFields.LastName; var _r = App.AuthPublic.Friends.Get(_friends); foreach (var tmp in _r) { GetPeopleList.Add((int)tmp.Id, tmp.FirstName + " " + tmp.LastName); } }
public void GetFriends() { for (int i = 0; i < users_count; i++) { if (!users_api[i].IsAuthorized) { continue; } FriendsGetParams getParams = new FriendsGetParams(); getParams.Fields = ProfileFields.FirstName | ProfileFields.LastName; getParams.Order = FriendsOrder.Name; VkCollection <User> friends = null; try { friends = users_api[i].Friends.Get(getParams, true); } catch (VkApiException ex) { continue; } List <FriendsListItem> friendsItems = new List <FriendsListItem>(); foreach (User friend in friends) { FriendsListItem friendItem = new FriendsListItem(); friendItem.User = new UserInfo(); friendItem.Friend = new UserInfo(); friendItem.SocialNetworkName = getSocialNetworkName(); friendItem.Friend.Name = String.Format("{0} {1}", friend.FirstName, friend.LastName); friendItem.Friend.ID = Convert.ToString(friend.Id); friendItem.User.Name = getUserAccountName(i); friendItem.User.ID = Convert.ToString(users_api[i].UserId); friendsItems.Add(friendItem); } applicationContract.AddItemsToFriendsList(friendsItems); } }
public ReadOnlyCollection <User> Get(long uid, ProfileFields fields = null, int?count = null, int?offset = null, FriendsOrder order = null, NameCase nameCase = null, int?listId = null) { if (listId != null && listId < 0) { throw new ArgumentOutOfRangeException("listId", "listId must be a positive number."); } var parameters = new FriendsGetParams { UserId = uid, Count = count, Offset = offset, Fields = fields, NameCase = nameCase, ListId = listId, Order = order }; return(Get(parameters).ToReadOnlyCollection()); }
private void MainLoop() { while (true) { var breakFlag = false; var friendsGetParam = new FriendsGetParams(); friendsGetParam.Fields = ProfileFields.Nickname; var friends = _vk.Friends.Get(friendsGetParam); var messagesGetHistoryParams = new MessagesGetHistoryParams(); foreach (User friend in friends) { messagesGetHistoryParams.UserId = friend.Id; var messages = _vk.Messages.GetHistory(messagesGetHistoryParams).Messages; foreach (Message message in messages) { _Log($"Request from {friend.FirstName} {friend.LastName}: {message.Body}"); if (ProcessMessage(message.Body)) { breakFlag = true; } } var ids = messages.Select(x => (long)x.Id); if (ids.Any()) { _vk.Messages.MarkAsRead(ids, null); } _vk.Messages.DeleteDialog(friend.Id); } if (breakFlag) { break; } Thread.Sleep(1000); } }
public List <UserExtended> GetFriends(long userId) { using (var api = _apiFactory.CreateVkApi()) { try { var param = new FriendsGetParams() { UserId = userId, Fields = ProfileFields.All }; var friends = api.Friends.Get(param); var result = friends.Select(x => new UserExtended(x)).ToList(); return(result); } catch (Exception e) { Console.WriteLine(e.Message); return(new List <UserExtended>()); } } }
public VKHandler(string login, string password) { var service = new ServiceCollection(); service.AddAudioBypass(); vk = new VkApi(service); vk.Authorize(new ApiAuthParams { ApplicationId = AppId, Login = login, Password = password, Settings = Settings.Friends }); var filter = new FriendsGetParams { Fields = ProfileFields.FirstName | ProfileFields.LastName }; friends = vk.Friends.Get(filter); random = new Random(); }
static void Main(string[] args) { var vk = new VkApi(); try { vk.Authorize(new ApiAuthParams() { Login = LOGIN, Password = PASSWORD, ApplicationId = APP_ID, Settings = Settings.Messages }); } catch (Exception e) { Console.WriteLine("Authorization has been failed!"); Console.WriteLine("Error{0}", e.ToString()); return; } Console.WriteLine("Authorization passed successfully..."); var friendsGetParam = new FriendsGetParams(); var friends = vk.Friends.Get(friendsGetParam); var msgGetParams = new MessagesGetHistoryParams(); msgGetParams.UserId = friends.First().Id; var msgHistory = vk.Messages.GetHistory(msgGetParams); foreach (Message msg in msgHistory.Messages) { var shift = (msg.Type == MessageType.Received) ? "" : "\t\t"; Console.WriteLine($"{shift}{msg.Body}"); } }
public VkCollection <User> Get(FriendsGetParams @params, bool skipAuthorization = true) { return(_vk.Call("friends.get", @params, skipAuthorization).ToVkCollectionOf(x => @params.Fields != null ? x : new User { Id = x })); }
/// <inheritdoc /> public Task <VkCollection <User> > GetAsync(FriendsGetParams @params, bool skipAuthorization = false) { return(TypeHelper.TryInvokeMethodAsync(func: () => _vk.Friends.Get(@params: @params, skipAuthorization: skipAuthorization))); }
/// <summary> /// Возвращает список идентификаторов друзей пользователя или расширенную информацию о друзьях пользователя (при использовании параметра fields). /// </summary> /// <param name="params">Входные параметры выборки.</param> /// <param name="skipAuthorization">Если <c>true</c>, то пропустить авторизацию</param> /// <returns> /// После успешного выполнения возвращает список идентификаторов (id) друзей пользователя, если параметр fields не использовался. /// При использовании параметра fields возвращает список объектов пользователей, но не более 5000. /// </returns> /// <remarks> /// Страница документации ВКонтакте <see href="http://vk.com/dev/friends.get" />. /// </remarks> public VkCollection<User> Get(FriendsGetParams @params, bool skipAuthorization = false) { return _vk.Call("friends.get", @params, skipAuthorization).ToVkCollectionOf(x => @params.Fields != null ? x : new User { Id = x }); }
public VkCollection <User> Get(FriendsGetParams @params) { return(_vk.Call("friends.get", @params).ToVkCollectionOf(x => @params.Fields != null ? x : new User { Id = x })); }