itkfm/

geras-sdk

用于将 GERAS 身份验证集成到应用程序中的 SDK

v3.3.0-beta 2023-09-20 13:17 UTC

This package is auto-updated.

Last update: 2024-09-20 15:24:33 UTC


README

用于将 GERAS 身份验证集成到应用程序中的 SDK

用法

通过 Composer 安装:composer require itkfm/geras-sdk

// Server URL
$gerasServerApiUrl = 'https://geras.test/api';
// Application ID (as registered on the server)
$gerasApplicationID = 1234;
// Secret API key (Base64 encoded) of the Application
$mySecretKey = '';

// Configure API key
$apiKey = new ApiKey($gerasServerApiUrl, $gerasApplicationID, $mySecretKey);

// Choose your API Client implementation
// `HttpApiClient` (built upon Guzzle) is provided out of the box
// You can also implement your own one, see `ApiClientInterface`
$transportLayer = new HttpApiClient($apiKey, new GuzzleHttp\Client());

// Setup dependencies
$messagePacker = new MessagePacker(new JsonMapper());

// Create client
$geras = new GerasClient($transportLayer, $messagePacker);