Skip to content

be-lenka/trustpilot-php-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Trustpilot PHP SDK

TrustPilot API library for PHP

composer require be-lenka/trustpilot-php-sdk

Initialize

use TrustPilot\TrustPilot;

$username = '<login_email>';
$password = '<login_password>';

// https://businessapp.b2b.trustpilot.com/applications/
$apiKey = '<api_key>';
$apiSecret = '<api_secret>';

$trustpilot = new TrustPilot($apiKey, $apiSecret);
$token = $trustpilot
    ->authorize()
    ->createPasswordToken($username, $password)
;
$trustpilot->setToken($token);

Find businessUnitId

$unit = $trustpilot->businessUnit()->find('belenka.com');   
$businessUnitId = $unit->id;

Fetch reviews

$data = [
    'perPage' => 1
];
$reviews = $trustpilot->businessUnit()->getReviews($businessUnitId, $data);

Create invite link

$data = [
    "referenceId" => "INV0001",
    "email" => "[email protected]",
    "name" => "John Doe",
    "locale" => "en-US",
    //"tags" => [
    //    "tag1",
    //    "tag2"
    //],
    "redirectUri" => "https://www.belenka.com"
];
$inviteLink = $tp->invitation()->generateInvitationLink($businessUnitId, $data);

Create invite

// https://businessapp.b2b.trustpilot.com/invitations/editor
$templateId = '<templateId>';
$data = [
    "replyTo" => '[email protected]',
    "locale" => "en-US",
    "referenceId" => "INV0000123",
    "recipientName" => "Majkl Najt",
    "recipientEmail" => '[email protected]',
    "type" => "invite",
    "templateId" => $templateId,
    "preferredSendTime" => "09/01/2024 15:07:00",
    "redirectUri" => "https://www.belenka.com",
];
$invite = $tp->invitation()->createEmailInvitation($businessUnitId, $data);

About

Trustpilot PHP SDK

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •  

Languages