C-Sharp

C# Example

Headers

Name
Value

Content-Type

application/json

Authorization

Key <token>

Name
Description

licenseKey

License key provided by the bot.

productName

Name of the product.

version

Current product version.

userId

Customer discord user Id.

hwid

Hardware Id of the user.

namespace YOURAPPNAME {
    class Program {
        public static void Main(string[] args) {
            Program.IntLicense();
        }
        
        public static async void IntLicense() {
            string url = "http://<DOMAIN>:<PORT>/api/v1/key";
            string licenseKey = "";
            string product = "";
            string version = "";
            string userId = "";
            string token = "";

            string hwid = WindowsIdentity.GetCurrent().User.Value;

            var options = new
            {
                licenseKey,
                product,
                hwid,
                version
            };

            var client = new HttpClient();
            var jsonOptions = System.Text.Json.JsonSerializer.Serialize(options);

            var content = new StringContent(jsonOptions, System.Text.Encoding.UTF8, "application/json");
            client.DefaultRequestHeaders.Add("Authorization", "Key " + token);

            var response = await client.PostAsync(url, content);
            var res = await response.Content.ReadAsStringAsync();
            var parsedText = System.Text.Json.JsonSerializer.Deserialize<LicenseResponse>(res);

            if ([400, 403, 404].includes(parsedText.status))
            {
                Task.Delay(3000);
                Console.WriteLine("\n");
                Console.WriteLine("Validation failed ⟶  " + "( " + licenseKey + " )");
                Console.WriteLine(" ");
                Console.WriteLine("Reason: " + "( " + parsedText.message + " )");
                Thread.Sleep(5);
                Environment.Exit(1);
            }
            else if (parsedText.status == 200)
            {
                Task.Delay(3000);
                Console.WriteLine("\n");
                Console.WriteLine("License validated ⟶  " + "( " + licenseKey + " )");
                Console.WriteLine(" ");
                Console.WriteLine("Message: " + "( You can now use: " + Environment.UserName + ") ");
            }
            else
            {
                Task.Delay(3000);
                Console.WriteLine("\n");
                Console.WriteLine("Validation failed ⟶  " + "( " + licenseKey + " )");
                Console.WriteLine(" ");
                Console.WriteLine("Reason: " + "( " + parsedText.message + " )");
                Thread.Sleep(5);
                Environment.Exit(1);
            }
        }
        
        class LicenseResponse
        {
            public int status { get; set; }
            public string message { get; set; }
        }
    }
}

Last updated