-
Notifications
You must be signed in to change notification settings - Fork 24
/
post_to_imgur.cs
35 lines (35 loc) · 1.39 KB
/
post_to_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
string post_data = "----------------------8d58d7876f67e5b"+"\n"+
"Content-Disposition: form-data; name=\"image\""+"; filename=\""+ "1.jpg"+"\"\n"+
"Content-Type: image/jpg"+"\n"+project.Path + "error\\" + "1.jpg"+"\n"+
"----------------------8d58d7876f67e5b--";
int query_count = 0;
string answer = string.Empty;
while(answer==""){
answer = ZennoPoster.HttpPost(
"https://api.imgur.com/3/image",post_data,
"multipart/form-data",
"",
"utf-8",
ZennoLab.InterfacesLibrary.Enums.Http.ResponceType.HeaderAndBody,
30000,"","ShareX",true,10,
new [] {
"Host: api.imgur.com",
"Authorization: Client-ID d297fd441566f99",
"Content-Type: multipart/form-data; boundary=--------------------8d58d7876f67e5b",
"Connection: keep-alive"
}
);
if (++query_count>=5 && answer=="")
{
project.Variables["answer"].Value = "";
throw new Exception("[Финальная отправка данных логина: пустой ответ 5 раз(а) подряд]");
}
}
project.Variables["post_info"].Value = answer;
//парсим нашу картинку //(?<="id":").*?(?=")
string pic="";
try{pic = Convert.ToString(Regex.Match(answer, @"(?<=id"":"").*?(?="")")).Trim();}catch{}
project.Variables["id_pic"].Value = pic;
string deletehash="";
try{deletehash = Convert.ToString(Regex.Match(answer, @"(?<=deletehash"":"").*?(?="")")).Trim();}catch{}
project.Variables["deletehash"].Value = deletehash;