mirror of
https://github.com/openbullet/openbullet.git
synced 2023-10-21 07:33:42 -05:00
DBC response fix.
This commit is contained in:
@@ -52,11 +52,22 @@ namespace RuriLib.CaptchaServices
|
||||
content.Add(new Extreme.Net.StringContent("4"), "type");
|
||||
content.Add(new Extreme.Net.StringContent(JsonConvert.SerializeObject(new CreateRecaptchaTaskRequest(siteUrl, siteKey))), "token_params");
|
||||
var response = request.Post("http://api.dbcapi.me/api/captcha", content).ToString();
|
||||
var split = response.Split('&');
|
||||
var status = int.Parse(split[0].Split('=')[1]);
|
||||
var id = split[1].Split('=')[1];
|
||||
if (status == 255) throw new Exception(response);
|
||||
TaskId = id;
|
||||
|
||||
// Sometimes the DBC API replies without JSON even when the Accept header is set correctly, so we must perform a check
|
||||
if (response.Trim().StartsWith("{"))
|
||||
{
|
||||
var taskResponse = JsonConvert.DeserializeObject<CreateTaskResponse>(response);
|
||||
if (taskResponse.status == 255) throw new Exception(taskResponse.error);
|
||||
TaskId = taskResponse.captcha;
|
||||
}
|
||||
else // Not JSON
|
||||
{
|
||||
var split = response.Split('&');
|
||||
var status = int.Parse(split[0].Split('=')[1]);
|
||||
var id = split[1].Split('=')[1];
|
||||
if (status == 255) throw new Exception(response);
|
||||
TaskId = id;
|
||||
}
|
||||
Status = CaptchaStatus.Processing;
|
||||
|
||||
// Check if task has been completed
|
||||
@@ -91,11 +102,22 @@ namespace RuriLib.CaptchaServices
|
||||
content.Add(new Extreme.Net.StringContent(Pass), "password");
|
||||
content.Add(new Extreme.Net.StringContent($"base64:{GetBase64(bitmap, ImageFormat.Jpeg)}"), "captchafile");
|
||||
var response = request.Post("http://api.dbcapi.me/api/captcha", content).ToString();
|
||||
var split = response.Split('&');
|
||||
var status = int.Parse(split[0].Split('=')[1]);
|
||||
var id = split[1].Split('=')[1];
|
||||
if (status == 255) throw new Exception(response);
|
||||
TaskId = id;
|
||||
|
||||
// Sometimes the DBC API replies without JSON even when the Accept header is set correctly, so we must perform a check
|
||||
if (response.Trim().StartsWith("{"))
|
||||
{
|
||||
var taskResponse = JsonConvert.DeserializeObject<CreateTaskResponse>(response);
|
||||
if (taskResponse.status == 255) throw new Exception(taskResponse.error);
|
||||
TaskId = taskResponse.captcha;
|
||||
}
|
||||
else // Not JSON
|
||||
{
|
||||
var split = response.Split('&');
|
||||
var status = int.Parse(split[0].Split('=')[1]);
|
||||
var id = split[1].Split('=')[1];
|
||||
if (status == 255) throw new Exception(response);
|
||||
TaskId = id;
|
||||
}
|
||||
Status = CaptchaStatus.Processing;
|
||||
|
||||
// Check if task has been completed
|
||||
|
||||
Reference in New Issue
Block a user