Exemplo n.º 1
0
 static public void Authenticate()
 {
     authForm = new AuthForm();
     authForm.ShowDialog();
     if (authForm.Token != null)
     {
         token = authForm.Token;
         Uid   = authForm.User;
         api   = new VkApi();
         api.Authorize(new ApiAuthParams()
         {
             AccessToken = token
         });
         VkNet.Model.RequestParams.AccountSaveProfileInfoParams s = api.Account.GetProfileInfo();
         Fname = s.FirstName;
         Lname = s.LastName;
     }
 }
Exemplo n.º 2
0
        static public void FormLoad()
        {
            string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/VKTest/token";

            if (File.Exists(path))
            {
                StreamReader sr = new StreamReader(path);
                try
                {
                    token = Decrypt(sr.ReadLine());
                    api   = new VkApi();
                    api.Authorize(new ApiAuthParams()
                    {
                        AccessToken = token
                    });
                    if (!api.IsAuthorized)
                    {
                        MessageBox.Show("Закончилось время авторизации, авторизуйтесь снова");
                        Token = null;
                    }
                    else
                    {
                        VkNet.Model.RequestParams.AccountSaveProfileInfoParams s = api.Account.GetProfileInfo();
                        Fname = s.FirstName;
                        Lname = s.LastName;
                        Uid   = api.Users.Get(new List <long> {
                        }).FirstOrDefault().Id.ToString();
                    }
                }
                catch
                {
                    MessageBox.Show("Ошибка авторизации, авторизуйтесь снова");
                    Token = null;
                }
                sr.Close();
            }
        }