JavaScript/Node.js Example
Copy
// License activation example
async function activateLicense(licenseKey, hardwareId, email) {
try {
const response = await fetch('https://bb.oyunbilgisi.com/api/activate.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
license_key: licenseKey,
hardware_id: hardwareId,
email: email
})
});
const result = await response.json();
if (result.success) {
console.log('License activated successfully!');
console.log('Activation ID:', result.activation_id);
console.log('Expires at:', result.expires_at);
return result;
} else {
console.error('Activation failed:', result.error);
throw new Error(result.error);
}
} catch (error) {
console.error('API Error:', error.message);
throw error;
}
}
// License verification example
async function verifyLicense(licenseKey, hardwareId = null) {
try {
const payload = { license_key: licenseKey };
if (hardwareId) payload.hardware_id = hardwareId;
const response = await fetch('https://bb.oyunbilgisi.com/api/verify.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(payload)
});
const result = await response.json();
if (result.success && result.valid) {
console.log('License is valid!');
return result.license_info;
} else {
console.log('License is invalid:', result.error);
return null;
}
} catch (error) {
console.error('Verification failed:', error.message);
return null;
}
}
// Usage
activateLicense('ABCD-EFGH-IJKL-MNOP', 'HW-123456', 'user@example.com')
.then(result => {
console.log('Activation successful:', result);
})
.catch(error => {
console.error('Activation failed:', error);
});
Python Example
Copy
import requests
import json
class LicenseAPI:
def __init__(self, base_url='https://bb.oyunbilgisi.com/api/'):
self.base_url = base_url
self.session = requests.Session()
self.session.headers.update({'Content-Type': 'application/json'})
def activate_license(self, license_key, hardware_id, email):
"""Activate a license on specified device"""
url = f"{self.base_url}activate.php"
data = {
'license_key': license_key,
'hardware_id': hardware_id,
'email': email
}
try:
response = self.session.post(url, json=data)
result = response.json()
if result.get('success'):
print(f"License activated successfully! ID: {result.get('activation_id')}")
return result
else:
raise Exception(result.get('error', 'Unknown error'))
except requests.RequestException as e:
raise Exception(f"API request failed: {str(e)}")
def verify_license(self, license_key, hardware_id=None):
"""Verify license validity"""
url = f"{self.base_url}verify.php"
data = {'license_key': license_key}
if hardware_id:
data['hardware_id'] = hardware_id
try:
response = self.session.post(url, json=data)
result = response.json()
return result.get('success', False) and result.get('valid', False)
except requests.RequestException as e:
print(f"Verification failed: {str(e)}")
return False
def deactivate_license(self, license_key, hardware_id):
"""Deactivate license on specified device"""
url = f"{self.base_url}deactivate.php"
data = {
'license_key': license_key,
'hardware_id': hardware_id
}
try:
response = self.session.post(url, json=data)
result = response.json()
if result.get('success'):
print("License deactivated successfully!")
return True
else:
raise Exception(result.get('error', 'Unknown error'))
except requests.RequestException as e:
raise Exception(f"API request failed: {str(e)}")
# Usage example
api = LicenseAPI()
try:
# Activate license
result = api.activate_license(
'ABCD-EFGH-IJKL-MNOP-QRST-UVWX-YZ12-3456',
'HW-PYTHON-123456-ABCDEF',
'user@example.com'
)
# Verify license
is_valid = api.verify_license(
'ABCD-EFGH-IJKL-MNOP-QRST-UVWX-YZ12-3456',
'HW-PYTHON-123456-ABCDEF'
)
print(f"License is valid: {is_valid}")
except Exception as e:
print(f"Error: {e}")
C# Example
Copy
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
public class LicenseAPI
{
private readonly HttpClient _httpClient;
private readonly string _baseUrl;
public LicenseAPI(string baseUrl = "https://bb.oyunbilgisi.com/api/")
{
_baseUrl = baseUrl;
_httpClient = new HttpClient();
_httpClient.DefaultRequestHeaders.Add("Content-Type", "application/json");
}
public async Task ActivateLicenseAsync(string licenseKey, string hardwareId, string email)
{
var data = new
{
license_key = licenseKey,
hardware_id = hardwareId,
email = email
};
var json = JsonConvert.SerializeObject(data);
var content = new StringContent(json, Encoding.UTF8, "application/json");
try
{
var response = await _httpClient.PostAsync($"{_baseUrl}activate.php", content);
var responseJson = await response.Content.ReadAsStringAsync();
var result = JsonConvert.DeserializeObject(responseJson);
return result;
}
catch (Exception ex)
{
throw new Exception($"API request failed: {ex.Message}");
}
}
public async Task VerifyLicenseAsync(string licenseKey, string hardwareId = null)
{
var data = new { license_key = licenseKey };
if (!string.IsNullOrEmpty(hardwareId))
{
data = new { license_key = licenseKey, hardware_id = hardwareId };
}
var json = JsonConvert.SerializeObject(data);
var content = new StringContent(json, Encoding.UTF8, "application/json");
try
{
var response = await _httpClient.PostAsync($"{_baseUrl}verify.php", content);
var responseJson = await response.Content.ReadAsStringAsync();
dynamic result = JsonConvert.DeserializeObject(responseJson);
return result.success == true && result.valid == true;
}
catch
{
return false;
}
}
public void Dispose()
{
_httpClient?.Dispose();
}
}
// Usage example
class Program
{
static async Task Main(string[] args)
{
var api = new LicenseAPI();
try
{
// Activate license
var result = await api.ActivateLicenseAsync(
"ABCD-EFGH-IJKL-MNOP-QRST-UVWX-YZ12-3456",
"HW-CSHARP-123456-ABCDEF",
"user@example.com"
);
Console.WriteLine($"Activation result: {result}");
// Verify license
var isValid = await api.VerifyLicenseAsync(
"ABCD-EFGH-IJKL-MNOP-QRST-UVWX-YZ12-3456",
"HW-CSHARP-123456-ABCDEF"
);
Console.WriteLine($"License is valid: {isValid}");
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
finally
{
api.Dispose();
}
}
}
PHP Example
Copy
Error: API request failed