Пример #1
0
        public string patchClypItUpload(MainWindow.ClypSession Clyp, ClypUploadResponse Response)
        {
            using (var client = new HttpClient())
            {
                MultipartFormDataContent content = new MultipartFormDataContent();

                Dictionary <string, string> formData = new Dictionary <string, string>()
                {
                    { "title", trackTitle.Text },
                    { "description", trackDescription.Text }
                };

                if (publicButton.Foreground == new SolidColorBrush(Colors.White))
                {
                    // Must be public //
                    formData.Add("status", "Public");
                }
                else
                {
                    // Must be private then //
                    formData.Add("status", "Private");
                }

                client.DefaultRequestHeaders.TryAddWithoutValidation("postman-token", "f6065275-baf8-91a9-e816-188061ac03a1");
                client.DefaultRequestHeaders.TryAddWithoutValidation("cache-control", "no-cache");
                client.DefaultRequestHeaders.TryAddWithoutValidation("authorization", "Bearer " + Clyp.access_token);
                client.DefaultRequestHeaders.TryAddWithoutValidation("x-client-type", "WebAlfa");
                client.DefaultRequestHeaders.TryAddWithoutValidation("content-type", "application/x-www-form-urlencoded; charset=UTF-8");

                return(client.PatchAsync("https://api.clyp.it/" + Response.AudioFileId, content).Result.Content.ReadAsStringAsync().Result);
            }
        }
Пример #2
0
 public Notifications(MainWindow.ClypSession Clyp)
 {
     InitializeComponent();
     if (Clyp.access_token == null)
     {
         notLoggedInLabel.Visibility = Visibility.Visible;
     }
     else
     {
         notLoggedInLabel.Visibility = Visibility.Hidden;
         if (Clyp.user.NotificationsSummary.Count > 0)
         {
             ClypNotifications Notifications = JsonConvert.DeserializeObject <ClypNotifications>(MainWindow.ClypQuery("https://api.clyp.it/me/notifications",
                                                                                                                      HttpMethod.Get,
                                                                                                                      new Dictionary <string, string>()
             {
                 { "authorization", "Bearer " + Clyp.access_token }, { "Content-Type", "application/x-www-form-urlencoded" }, { "x-client-type", "WebAlfa" }
             },
                                                                                                                      new Dictionary <string, string>()
             {
                 { "count", "5" }
             },
                                                                                                                      Clyp));
             createNotifications(Notifications);
         }
     }
 }
Пример #3
0
 public Uploading(MainWindow.ClypSession Clyp, string FilePath)
 {
     InitializeComponent();
     this.Clyp     = Clyp;
     this.filepath = FilePath;
     try
     {
         username.Content       = "Logged in as: " + Clyp.user.FirstName;
         authenticated          = true;
         notLoggedIn.Visibility = Visibility.Hidden;
     }
     catch
     {
         // Not logged in and should upload anonymously //
         // authenticated stays as false //
         notLoggedIn.Visibility = Visibility.Visible;
     }
 }
Пример #4
0
        private string postToClypIt(MainWindow.ClypSession Clyp, string FilePath, bool auth)
        {
            using (var client = new HttpClient())
            {
                MultipartFormDataContent form = new MultipartFormDataContent();
                FileStream file        = File.OpenRead(FilePath);
                var        droppedFile = new ByteArrayContent(new StreamContent(file).ReadAsByteArrayAsync().Result);
                droppedFile.Headers.ContentType = MediaTypeHeaderValue.Parse("multipart/form-data; boundary=----WebKitFormBoundaryB27eCApzWWdpf4x3");

                client.DefaultRequestHeaders.TryAddWithoutValidation("postman-token", "f6065275-baf8-91a9-e816-188061ac03a1");
                client.DefaultRequestHeaders.TryAddWithoutValidation("cache-control", "no-cache");

                if (auth)
                {
                    client.DefaultRequestHeaders.TryAddWithoutValidation("authorization", "Bearer " + Clyp.access_token);
                }

                client.DefaultRequestHeaders.TryAddWithoutValidation("x-client-type", "WebAlfa");

                form.Add(droppedFile, "file", Path.GetFileName(FilePath));
                var response = client.PostAsync("https://upload.clyp.it/upload", form).Result;
                return(response.Content.ReadAsStringAsync().Result);
            }
        }