Exemplo n.º 1
0
        static void GetPostsFromVkViaApi()
        {
            PostAdministration administration = new PostAdministration();
            var vkAuth = new VkAuthParams();

            Console.WriteLine("Enter login: "******"Enter id or username, which posts need to calcualte");
                        string postOwner = Console.ReadLine();
                        if (String.IsNullOrWhiteSpace(postOwner))
                        {
                            break;
                        }
                        List <VkNet.Model.Attachments.Post> posts = administration.GetPostsFromUsername(vkApi, postOwner);
                        if (posts != null)
                        {
                            string userActivityStatisctics = UserPostActivityConvertor.ConvertListToJson(posts);
                            administration.SetWallPostActivityToUsername(vkApi, userActivityStatisctics);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
        }
Exemplo n.º 2
0
        //Создадим функцию, которая будет возвращать поля, необходимые для аутентификации
        private VkAuthParams GetApiAuthParams(string username)
        {
            const ulong APPLICATION_ID = 6810122;
            var         auth_params    = new VkAuthParams();

            if (!String.IsNullOrWhiteSpace(username))
            {
                auth_params.ApplicationId          = APPLICATION_ID;
                auth_params.Login                  = username;
                auth_params.Password               = SecureStringToString(VkPassword());
                auth_params.Settings               = Settings.Wall;
                auth_params.TwoFactorAuthorization = () =>
                {
                    Console.WriteLine("Enter code, if you enable double-auth security. If you dont'use it-press Enter");
                    return(Console.ReadLine());
                };

                return(auth_params);
            }
            else
            {
                throw new ArgumentNullException(username, "Enter login to authentication");
            }
        }