trstd / cot-integration-library
这是一个连接到信任社区平台(Community of Trust)的PHP集成库。
1.1.0
2024-08-23 14:35 UTC
Requires
- php: >=7.4
- firebase/php-jwt: ^6
- monolog/monolog: ^2
- phpfastcache/phpfastcache: ^8
- phpseclib/phpseclib: ^3
- symfony/http-client: ^5
Requires (Dev)
README
此库为与信任社区平台(COT)集成提供了全面的PHP接口,便于与服务进行无缝交互。
要求
- PHP >= 7.4
- Composer用于管理依赖项
安装
要安装库,请在项目目录中运行以下命令
composer require trstd/cot-integration-library
用法
以下是如何使用此库的基本示例
在后端
<?php require_once 'vendor/autoload.php'; use TRSTD\COT\Client; // Initialize the client $client = new Client( <TSID>, // Trusted Shops ID - e.g. 'X1234567890123456789012345678901' <CLIENT_ID>, // Client ID - e.g. 'cot-switch-X1234567890123456789012345678901' <CLIENT_SECRET>, // Client Secret - e.g. '1234567890123456789012345678901234567890123456789012345678901234' <AUTH_STORAGE_INSTANCE> // It can be any storage option implementing AuthStorageInterface - e.g. new DatabaseAuthStorage() ); // Invoke handleCallback function to handle code coming from the authentication server $client->handleCallback(); // Get anonymous consumer data for the current user $client->getAnonymousConsumerData();
在前端,将以下代码放置在HTML文件中您希望小部件出现的位置
<trstd-switch tsId="X1234567890123456789012345678901"></trstd-switch> <script type="module" src="https://widgets.trustedshops.com/switch/switch.js"></script>
有关更多详细示例,请参阅examples/
目录。
贡献
欢迎贡献!请参阅CONTRIBUTING.md文件以获取指南。
许可证
此库根据MIT许可证授权 - 有关详细信息,请参阅LICENSE文件。
致谢
- 感谢firebase/php-jwt对JWT处理的支持
- 感谢phpseclib/phpseclib提供的安全功能
- 感谢monolog/monolog提供日志记录功能
- 感谢phpfastcache/phpfastcache提供缓存解决方案
- 感谢symfony/http-client提供的HTTP客户端功能
版本管理
本项目遵循语义版本控制。有关可用版本,请参阅此存储库的标签。
PHP包仓库
此库在Packagist上可用。