This library provides a comprehensive PHP interface for integrating with the Community of Trust (COT) platform, facilitating seamless interactions with its services.
- PHP >= 7.4
- Composer for managing dependencies
To install the library, run the following command in your project directory:
composer require trstd/cot-integration-library
Here is a basic example of how to use the library:
On the backend side:
<?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()
<ENV> // Environment (optional) - dev, qa, or prod, defaults to prod
);
// Invoke handleCallback function to handle code coming from the authentication server
$client->handleCallback();
// Get anonymous consumer data for the current user
$client->getAnonymousConsumerData();
On the frontend side, place the following code in your HTML file where you want the widget to appear:
<trstd-switch tsId="X1234567890123456789012345678901"></trstd-switch>
<script type="module" src="https://widgets.trustedshops.com/switch/switch.js"></script>
For more detailed examples, please refer to the examples/
directory.
Contributions are welcome! Please refer to the CONTRIBUTING.md file for guidelines.
This library is licensed under the MIT License - see the LICENSE file for details.
- firebase/php-jwt for JWT handling
- phpseclib/phpseclib for security features
- monolog/monolog for logging
- phpfastcache/phpfastcache for caching solutions
- symfony/http-client for HTTP client features
This project adheres to Semantic Versioning. For the versions available, see the tags on this repository.
This library is available on Packagist.