Пример #1
0
        private void GetFriends()
        {
            //comboBFriends.Items.Clear();
            _friendsFactory = new FriendsFactory(_manager);
            string[] fields = { "uid", "first_name", "last_name" };
            _friendsList = _friendsFactory.Get(_sessionInfo.UserId, "nom", null, 0, null, fields);

            foreach (Friend a in _friendsList)
            {
                comboBFriends.Items.Add(a);
            }
        }
Пример #2
0
        private void Reauth()
        {
            if (!this.isLoggedIn)
            {
                SessionManager sm = new SessionManager(1928531, Convert.ToInt32(ApiPerms.Audio | ApiPerms.ExtendedMessages | ApiPerms.ExtendedWall | ApiPerms.Friends | ApiPerms.Offers | ApiPerms.Photos | ApiPerms.Questions | ApiPerms.SendNotify | ApiPerms.SidebarLink | ApiPerms.UserNotes | ApiPerms.UserStatus | ApiPerms.Video | ApiPerms.WallPublisher | ApiPerms.Wiki));
                //sm.Log += new SessionManagerLogHandler(sm_Log);
                this.sessionInfo = sm.GetSession();
                if (this.sessionInfo != null)
                {
                    this.isLoggedIn = true;
                }
            }

            if (this.isLoggedIn)
            {
                manager = new ApiManager(this.sessionInfo);
                //manager.Log += new ApiManagerLogHandler(manager_Log);
                //manager.DebugMode = true;
                manager.Timeout = 10000;
                this.FriendList.Enabled = true;
                this.Text = this.appTitle + ": Authorization success!";

                this.friendFactory = new FriendsFactory(this.manager);
                this.photoFactory = new PhotosFactory(this.manager);
                this.photoList = new List<PhotoEntryFull>();
                this.albumList = new List<AlbumEntry>();
                this.userIdCheck = new Regex("([\\d])+$");
                this.GetFriendList();
            }
        }
Пример #3
0
        public void Auth()
        {
            //чтобы форма с авторизацией не фризила поток, а продолжала свою работу сразу после эвента
            //https://stackoverflow.com/questions/1916095/how-do-i-make-an-eventhandler-run-asynchronously
            //Task.Factory.FromAsync(
            //    (asyncCallback, @object) =>
            //    {
            //        var onConnecting = this.Connecting;
            //        return onConnecting != null ? onConnecting.BeginInvoke(this, GetNetworkName(), asyncCallback, @object) : null;
            //    },
            //    this.Connecting.EndInvoke, null);

            OnConnecting();
            ShareDestionation = ShareDestinations.Messages;
             _sessionManager = new SessionManager(2369574, "status,wall,photos,audio,messages");
            if (_needRelogin)
            {
                _sessionManager.ReLogin();
                _isLogged = false;
                _needRelogin = false;
            }
            if (!_isLogged)
            {

                // Соединяемся с VK API, передаем ему ключ приложения и необходимые нам разрешения

                _sessionInfo = _sessionManager.GetOAuthSession();

                if (_sessionInfo != null)
                {
                    _isLogged = true;
                }
                Auth();
            }

            // Выполняется если пользователь залогинен
            else
            {
                _manager = new ApiManager(_sessionInfo) { Timeout = 10000 };
                _statusFactory = new StatusFactory(_manager);
                _friendsFactory = new FriendsFactory(_manager);
                _audioFactory = new AudioFactory(_manager);
                _messagesFactory = new MessagesFactory(_manager);
                _photosFactory = new PhotosFactory(_manager);
                _wallFactory = new WallFactory(_manager);
                OnConnected(_sessionInfo.UserId.ToString());
            }
        }