示例#1
0
        private static void TestAuth()
        {
            // create the API
            MinusApi api = new MinusApi(API_KEY);

            //set up listeners for SignIn
            api.SignInFailed += delegate(MinusApi sender, Exception e)
            {
                Console.WriteLine("Failed to Sign In... " + e.Message);
            };
            api.SignInComplete += delegate(MinusApi sender, SignInResult result)
            {
                Console.WriteLine("Signed In: " + result.Success + ", " + result.CookieHeaders);
                api.MyGalleries(result.CookieHeaders);
            };

            //set up listeners for MyGalleries
            api.MyGalleriesFailed += delegate(MinusApi sender, Exception e)
            {
                Console.WriteLine("Failed to get galleries..." + e.Message);
            };
            api.MyGalleriesComplete += delegate(MinusApi sender, MyGalleriesResult result)
            {
                Console.WriteLine("Got galleries...");
                foreach (GalleryResult gallery in result.Galleries)
                {
                    Console.WriteLine(gallery.Name + " - " + gallery.LastVisit);
                }
            };

            api.SignIn("123test123", "123test123");
        }
示例#2
0
        public Minus()
        {
            queuedFiles = new List<string>();
            uploadedFiles = new List<String>();

            recipients = new List<string>();

            api = new MinusApi(ApiKey);

            LoginStatus = LoginStatus.None;
        }
示例#3
0
        /// <summary>
        /// Tests the full scope of methods in the API.
        /// This method creates a gallery, uploads a couple of items, saves them and then retrieves them.
        /// Make sure you change the values of the items in the "items" array to match actually valid files or this
        /// will fail.
        /// </summary>
        private static void TestAll()
        {
            // The call that triggers the program is the near the end of this method
            // (the rest is pretty much setup to react to events)

            // create the API
            MinusApi api = new MinusApi(API_KEY);

            // Prepare the items to be uploaded
            String[] items =
            {
                @"C:\Users\bruno\Desktop\clown.png",
                @"C:\Users\bruno\Desktop\small.png"
            };
            IList<String> uploadedItems = new List<String>(items.Length);

            // create a couple of things we're going to need between requests
            CreateGalleryResult galleryCreated = null;

            // set up the listeners for CREATE
            api.CreateGalleryFailed += delegate(MinusApi sender, Exception e)
            {
                // don't do anything else...
                Console.WriteLine("Failed to create gallery..." + e.Message);
            };
            api.CreateGalleryComplete += delegate(MinusApi sender, CreateGalleryResult result)
            {
                // gallery created, trigger upload of the first file
                galleryCreated = result;
                Console.WriteLine("Gallery created! " + result);
                Thread.Sleep(1000);
                Console.WriteLine("Uploading files...");
                api.UploadItem(result.EditorId, result.Key, items[0]);
            };

            // set up the listeners for UPLOAD
            api.UploadItemFailed += delegate(MinusApi sender, Exception e)
            {
                // don't do anything else...
                Console.WriteLine("Upload failed: " + e.Message);
            };
            api.UploadItemComplete += delegate(MinusApi sender, UploadItemResult result)
            {
                // upload complete, either trigger another upload or save the gallery if all files have been uploaded
                Console.WriteLine("Upload successful: " + result);
                uploadedItems.Add(result.Id);
                if (uploadedItems.Count == items.Length)
                {
                    // if all the elements are uploaded, then save the gallery
                    Console.WriteLine("All uploads complete, saving gallery...");
                    api.SaveGallery("testGallery", galleryCreated.EditorId, galleryCreated.Key, uploadedItems.ToArray());
                }
                else
                {
                    // otherwise just keep uploading
                    Console.WriteLine("Uploading item " + (uploadedItems.Count + 1));
                    api.UploadItem(galleryCreated.EditorId, galleryCreated.Key, items[uploadedItems.Count]);
                }
            };

            // set up the listeners for SAVE
            api.SaveGalleryFailed += delegate(MinusApi sender, Exception e)
            {
                Console.WriteLine("Failed to save gallery... " + e.Message);
            };
            api.SaveGalleryComplete += delegate(MinusApi sender)
            {
                // The extra "m" is appended because minus uses the first character to determine the type of data
                // you're accessing (image, gallery, etc) and route you accordingly.
                Console.WriteLine("Gallery saved! You can now access it at http://min.us/m" + galleryCreated.ReaderId);
                api.SignIn("123test123", "123test123");
            };

            //set up listeners for SignIn
            api.SignInFailed += delegate(MinusApi sender, Exception e)
            {
                Console.WriteLine("Failed to Sign In... " + e.Message);
            };
            api.SignInComplete += delegate(MinusApi sender, SignInResult result)
            {
                Console.WriteLine("Signed In: " + result.Success);
            };

            // this is the call that actually triggers the whole program
            api.CreateGallery();
        }
示例#4
0
        /// <summary>
        /// This method
        /// </summary>
        private static void TestGetItems()
        {
            // create the API
            MinusApi api = new MinusApi(API_KEY);

            // setup the success handler for GetItems operation
            api.GetItemsComplete += delegate(MinusApi sender, GetItemsResult result)
            {
                Console.WriteLine("Gallery items successfully retrieved!\n---");
                Console.WriteLine("Read-only URL: " + result.ReadonlyUrl);
                Console.WriteLine("Title: " + result.Title);
                Console.WriteLine("Items:");
                foreach (String item in result.Items)
                {
                    Console.WriteLine(" - " + item);
                }
            };

            // setup the failure handler for the GetItems operation
            api.GetItemsFailed += delegate(MinusApi sender, Exception e)
            {
                // don't do anything else...
                Console.WriteLine("Failed to get items from gallery...\n" + e.Message);
            };

            // trigger the GetItems operation - notice the extra "m" in there.
            // while the REAL reader id is "vgkRZC", the API requires you to put the extra "m" in there
            api.GetItems("mvgkRZC");
        }
示例#5
0
 static MinusUploader()
 {
     minusApi = new MinusApi("");
 }
示例#6
0
        private static void TestGuestUpload()
        {
            // create the API
            MinusApi api = new MinusApi(API_KEY);

            CreateGalleryResult galleryCreated = null;

            api.SignInComplete += delegate(MinusApi sender, SignInResult result)
            {
                api.CreateGallery(result.CookieHeaders);
            };

            api.CreateGalleryComplete += delegate(MinusApi sender, CreateGalleryResult result)
            {
                // gallery created, trigger upload of the first file
                galleryCreated = result;
                Console.WriteLine("Gallery created! " + result);
                Thread.Sleep(1000);
                Console.WriteLine("Uploading files...");
                //api.UploadItem(result.EditorId, result.Key, items[0]);
            };

            // this is the call that actually triggers the whole program
            api.SignIn();
        }