PHP code example of smart-contact / trustpilot-api-service

1. Go to this page and download the library: Download smart-contact/trustpilot-api-service 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/ */

    

smart-contact / trustpilot-api-service example snippets


use SmartContact/TrustpilotApiService/TrustpilotApiService;

$trustpilotService = new TrustpilotApiService();

$trustpilotService->init([
  'business_unit_id' => '123456789',
  'api_key' => 'abcdefghijklmnopqrstuvwxyz',
  'api_secret' => '123456789abcdefghi',
  'username' => '[email protected]',
  'password' => 'P4ssw0rd'
]);

//authenticate to get a valid token
$trustpilotService->authenticate(); // if you use the same instance, once you have authenticated the service will automatically refresh the token when it is expired

//get invitation templates
$data = $trustpilotService->getInvitationTemplates();

var_dump($data['templates']);