forked from michaelmob/Hyperdesktop2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcls_Imgur.cs
62 lines (53 loc) · 1.68 KB
/
cls_Imgur.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Drawing;
using System.Net;
using System.Text;
namespace hyperdesktop2
{
class Imgur
{
public static WebClient web_client = new WebClient();
public static Boolean upload(Bitmap bmp)
{
try
{
var data = new NameValueCollection();
var image = Global_Func.bmp_to_base64(bmp, Global_Func.ext_to_imageformat(Settings.upload_format));
data.Add("image", image);
web_client.Headers.Add("Authorization", "Client-ID " + Settings.imgur_client_id);
web_client.UploadValuesAsync(
new Uri("https://api.imgur.com/3/image/"),
"POST",
data
);
web_client.Headers.Remove("Authorization");
}
catch
{
return false;
}
return true;
}
public static Boolean delete(String delete_hash)
{
try
{
var web_client = new WebClient();
web_client.Headers.Add("Authorization", "Client-ID " + Settings.imgur_client_id);
web_client.UploadData(
new Uri("https://api.imgur.com/3/image/" + delete_hash),
"DELETE",
new Byte[] { 0x0 }
);
web_client.Dispose();
return true;
}
catch
{
return false;
}
}
}
}