PHP code example of reputify / reputify-php

1. Go to this page and download the library: Download reputify/reputify-php 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/ */

    

reputify / reputify-php example snippets


use Reputify\Reputify;

$reputify = new Reputify('rpf_live_…');   // Embed & Widgets → API & integrations

$profile = $reputify->projects->profile(12);
echo $profile['score']['value'];           // 88.8 — the same number as the seal

foreach ($reputify->reviews->list(12, ['min_rating' => 4, 'has_text' => true])->autoPaging() as $review) {
    echo $review['reviewer_name'], ': ', $review['text'], PHP_EOL;
}

$reputify->reviews->reply(12, 9182, 'Thank you, Anna!');

use Reputify\Resources\Embeds;

echo '<img src="'.Embeds::renderUrl('pk_1c8a…', '1a', 'svg').'" alt="Reputify">';

$reputify = new Reputify('rpf_inv_…');

$result = $reputify->invites->create([
    'name' => 'Anna Bauer',
    'email' => '[email protected]',
    'order_ref' => '2026-1188',              // twice = still one invitation
    'product_items' => ['SKU-4711', ['ref' => 'SKU-12', 'name' => 'Mug']],
]);

$result['status'];                           // "invited" or "already_invited"

use Reputify\Exception\{ApiException, PermissionException, ConflictException, RateLimitException, ValidationException};

try {
    $reputify->reviews->reply(12, 9182, 'Thanks!');
} catch (ConflictException $e) {           // reply_on_platform: answer on Google/Trustpilot itself
} catch (PermissionException $e) {         // $e->

use Reputify\OAuth;
use Reputify\Reputify;
use Reputify\TokenSet;

// Once per installation (every site has its own redirect URI):
$client = OAuth::register('My Shop Plugin', ['https://shop.example/reputify/callback']);

$oauth = new OAuth($client['client_id'], 'https://shop.example/reputify/callback');

// 1. Send the customer off
$pkce = OAuth::pkce();
$_SESSION['reputify'] = ['verifier' => $pkce['verifier'], 'state' => $state = bin2hex(random_bytes(16))];
header('Location: '.$oauth->authorizeUrl(['widgets:read', 'invites:write'], $state, $pkce['challenge']));

// 2. On the way back (check state first!)
$tokens = $oauth->exchangeCode($_GET['code'], $_SESSION['reputify']['verifier']);
save($tokens->toArray());

// 3. Use it
$reputify = new Reputify(TokenSet::fromArray(load()), [
    'oauth' => $oauth,
    'on_refresh' => fn (TokenSet $t) => save($t->toArray()),
]);
$reputify->site->get();

use Reputify\Webhook;

$event = Webhook::verify(
    file_get_contents('php://input'),
    $_SERVER['HTTP_X_REPUTIFY_SIGNATURE'] ?? null,
    $secret,                                  // from the survey, tab "Nach der Abgabe"
);

if ($event['event'] === Webhook::EVENT_SUBMITTED) { … }
bash
composer