Exemple #1
0
 private Dictionary <string, string> CreateDictionaryFrom(VkAppSettings settings, string code)
 {
     return(new Dictionary <string, string>
     {
         { "client_id", settings.ClientId },
         { "client_secret", settings.ClientSecret },
         { "redirect_uri", settings.RedirectUri },
         { "code", code }
     });
 }
        static void Main()
        {
            var vkAppSettings = new VkAppSettings("7096347",
                                                  "dfem1KnHOVrDN21VHckc", "http://blank.org/");

            var dialogManager = new ConsoleDialogManager();

            using var vkAuthenticator = new VkAuthenticator(vkAppSettings, dialogManager);

            vkAuthenticator.OpenCodePage();
            string code        = dialogManager.Ask();
            string accessToken = vkAuthenticator.GetAccessTokenAsync(code).Result;

            var api = vkAuthenticator.GetAuthorizedApiAsync(accessToken).Result;

            var vkPhotoUploader = new VkPhotoUploader(api, dialogManager);

            string[] photos  = vkPhotoUploader.GetFolderFiles();
            long     albumId = vkPhotoUploader.AlbumSelector();

            vkPhotoUploader.UploadPhotos(albumId, photos);

            Console.ReadKey();
        }
Exemple #3
0
 public VkAuthenticator(VkAppSettings settings, IDialogManager dialogManager)
 {
     this.client        = new HttpClient();
     this.settings      = settings;
     this.dialogManager = dialogManager;
 }