许可证验证示例

验证许可证

客户端代码示例

// 许可证验证函数
async function validateLicence(appId, apiKey, licenceKey, deviceId) {
  try {
    const response = await fetch('/licences/api/validate', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'X-App-Id': appId,
        'X-Api-Key': apiKey
      },
      body: JSON.stringify({ licenceKey, deviceId })
    });
    
    return await response.json();
  } catch (error) {
    console.error('验证许可证时出错:', error);
    return { valid: false, reason: 'network_error' };
  }
}