everlutionsk/citadel-client
Citadel API交互的客户端库
0.4.2
2024-07-02 09:36 UTC
Requires
- php: ^8.3
- guzzlehttp/guzzle: ^6.0
README
CitadelClient 是一个用于与 Citadel API 交互的 PHP 库。
安装
您可以通过 Composer 安装此库
composer require everlutionsk/citadel-client
使用
<?php require_once __DIR__ . '/vendor/autoload.php'; use CitadelClient\HttpClient; use CitadelClient\SessionResolveRequest; // Initialize the HTTP client $client = new HttpClient('https://api.citadel.example', 'your-pre-shared-key'); // Prepare the session resolve request $request = new SessionResolveRequest('your-cookie-header', 'your-client-id', 'your-client-secret'); try { // Resolve the session $response = $client->sessionResolve($request); // Handle the response if ($response->session) { echo "Session resolved successfully:\n"; echo "Session ID: " . $response->session->id . "\n"; // Other session details... } else { echo "No session resolved.\n"; echo "Recommended action: " . $response->recommended->action . "\n"; // Other recommendations... } } catch (\Exception $e) { // Handle errors echo "Error: " . $e->getMessage() . "\n"; }
将 'https://api.citadel.example', 'your-pre-shared-key', 'your-cookie-header', 'your-client-id', 和 'your-client-secret' 分别替换为您的实际 Citadel API 端点、预共享密钥、Cookie 标头、客户端 ID 和客户端密钥。