PHP code example of itspirit / trustpilot-invitation-api

1. Go to this page and download the library: Download itspirit/trustpilot-invitation-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

itspirit / trustpilot-invitation-api example snippets


use Trustpilot\Api\Authenticator\Authenticator;
use Trustpilot\Api\Invitation\Client;
use Trustpilot\Api\Invitation\Recipient;
use Trustpilot\Api\Invitation\Sender;
use Trustpilot\Api\Invitation\Context;

$authenticator = new Authenticator($apiKey, $apiToken, $username, $password);
$accessToken = $authenticator->getAccessToken();

$client = new Client($accessToken);

$context = new Context($businessUnitId, $templateId, $redirectUri);
// The last two arguments to the Context constructor ($tags and $locale) are optional
// $context = new Context($templateId, $redirectUri, $tags = array(), $locale = 'en-US');

$recipient = new Recipient($recipientEmail, $recipientName);
$sender    = new Sender($senderEmail, $senderName, $replyTo);

$client->invite($context, $recipient, $sender, $reference) /* : array */

use Trustpilot\Api\Authenticator\Authenticator;
use Trustpilot\Api\Invitation\Client;

$authenticator = new Authenticator($apiKey, $apiToken, $username, $password);
$accessToken = $authenticator->getAccessToken();

$client = new Client($accessToken);

$reviews = $client->getProductReviews(TRUSTPILOT_BUSINESS_UNIT_ID, null,
                ['published', 'unpublished', 'underModeration', 'archived'], 'de', $page, 100)