Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
zatvorius authored Mar 21, 2023
1 parent f4be47e commit 6e1606d
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
31 changes: 31 additions & 0 deletions TwoCaptcha.Examples/AudioCaptchaExample.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.IO;
using System.Linq;
using TwoCaptcha.Captcha;

namespace TwoCaptcha.Examples
{
internal class AudioCaptchaExample
{
public void Main()
{
TwoCaptcha solver = new TwoCaptcha("YOUR_API_KEY");

byte[] bytes = File.ReadAllBytes("../../resources/audio-en.mp3");
string base64EncodedImage = Convert.ToBase64String(bytes);

AudioCaptcha captcha = new AudioCaptcha();
captcha.SetBase64(base64EncodedImage);

try
{
solver.Solve(captcha).Wait();
Console.WriteLine("Captcha solved: " + captcha.Code);
}
catch (AggregateException e)
{
Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
}
}
}
}
32 changes: 32 additions & 0 deletions TwoCaptcha.Examples/AudioCaptchaOpdionsExample.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.IO;
using System.Linq;
using TwoCaptcha.Captcha;

namespace TwoCaptcha.Examples
{
internal class AudioCaptchaOptionsExample
{
public void Main()
{
TwoCaptcha solver = new TwoCaptcha("YOUR_API_KEY");

byte[] bytes = File.ReadAllBytes("../../resources/audio-ru.mp3");
string base64EncodedImage = Convert.ToBase64String(bytes);

AudioCaptcha captcha = new AudioCaptcha();
captcha.SetBase64(base64EncodedImage);
captcha.SetLang("ru");

try
{
solver.Solve(captcha).Wait();
Console.WriteLine("Captcha solved: " + captcha.Code);
}
catch (AggregateException e)
{
Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
}
}
}
}

0 comments on commit 6e1606d

Please sign in to comment.