https://github.com/justijndepover/trustpilot-api
PHP Client for the Trustpilot API
https://github.com/justijndepover/trustpilot-api
api php trustpilot
Last synced: about 2 months ago
JSON representation
PHP Client for the Trustpilot API
- Host: GitHub
- URL: https://github.com/justijndepover/trustpilot-api
- Owner: justijndepover
- License: mit
- Created: 2021-12-23T14:37:57.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-12-23T15:55:28.000Z (over 3 years ago)
- Last Synced: 2025-04-14T17:57:51.324Z (about 2 months ago)
- Topics: api, php, trustpilot
- Language: PHP
- Homepage:
- Size: 40 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Trustpilot API
[](https://packagist.org/packages/justijndepover/trustpilot-api)
[](LICENSE.md)
[](https://packagist.org/packages/justijndepover/trustpilot-api)PHP Client for the Trustpilot API
## Caution
This application is still in development and could implement breaking changes. Please use at your own risk.
## Installation
You can install the package with composer
```sh
composer require justijndepover/trustpilot-api
```## Installing the package in Laravel
To use the plugin in Laravel applications, please refer to the [Laravel usage page](docs/laravel-usage.md)
## Usage
Connecting to Trustpilot:
```php
$trustpilot = new Trustpilot(CLIENT_ID, CLIENT_SECRET, REDIRECT_URI);
// open the trustpilot login
header("Location: {$trustpilot->redirectForAuthorizationUrl()}");
exit;
```After connecting, Trustpilot will send a request back to your redirect uri.
```php
$trustpilot = new Trustpilot(CLIENT_ID, CLIENT_SECRET, REDIRECT_URI);if ($_GET['error']) {
// your application should handle this error
}$trustpilot->setAuthorizationCode($_GET['code']);
$trustpilot->connect();// store these values:
$accessToken = $trustpilot->getAccessToken();
$refreshToken = $trustpilot->getRefreshToken();
$expiresAt = $trustpilot->getTokenExpiresAt();
```Your application is now connected. To start fetching data:
```php
$trustpilot = new Trustpilot(CLIENT_ID, CLIENT_SECRET, REDIRECT_URI);
$trustpilot->setAccessToken($accessToken);
$trustpilot->setRefreshToken($refreshToken);
$trustpilot->setTokenExpiresAt($expiresAt);// fetch data:
$trustpilot->get($url);// you should always store your tokens at the end of a call
$accessToken = $trustpilot->getAccessToken();
$refreshToken = $trustpilot->getRefreshToken();
$expiresAt = $trustpilot->getTokenExpiresAt();
```## Security
If you find any security related issues, please open an issue or contact me directly at [[email protected]]([email protected]).
## Contribution
If you wish to make any changes or improvements to the package, feel free to make a pull request.
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.