1. Go to this page and download the library: Download toin0u/trustpilot 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/ */
toin0u / trustpilot example snippets
rustpilot\Trustpilot;
use Trustpilot\Cache\File;
use HttpAdapter\CurlHttpAdapter;
$cache = new File('> now - 1 hour', 'my_temporary_folder'); // optional
$adapter = new CurlHttpAdapter(); // the default one
$trustpilot = new Trustpilot(917278, $cache, $adapter);
try {
printf("Last update: %s\n", $trustpilot->getLastUpdate()->getHuman());
printf("Domain name: %s\n", $trustpilot->getDomainName());
printf("Page url: %s\n", $trustpilot->getUrl());
printf("Total reviews: %u\n", $trustpilot->getTotalReviews());
$distributionOverStars = $trustpilot->getDistributionOverStars();
printf("- 1: %u\n", $distributionOverStars[0]);
printf("- 2: %u\n", $distributionOverStars[1]);
printf("- 3: %u\n", $distributionOverStars[2]);
printf("- 4: %u\n", $distributionOverStars[3]);
printf("- 5: %u\n", $distributionOverStars[4]);
printf("Trust Score (between 0 and 100): %u\n", $trustpilot->getTrustScore()->getScore());
printf("Trust Score in stars (between 1 and 5): %u\n", $trustpilot->getTrustScore()->getStars());
printf("Trust Score: %s\n", $trustpilot->getTrustScore()->getReadableScore());
printf("Trust Score image url: %s\n", $trustpilot->getTrustScore()->getImageUrl('medium'));
foreach ($trustpilot->getReviews() as $review) {
printf("Review date: %s\n", $review->getTime()->getDateTime()->format('Y-m-d H:i:s'));
printf("Review title: %s\n", $review->getTitle());
printf("Review content: %s\n", $review->getContent());
printf("Review company reply: %s\n", $review->getCompanyReply());
printf("Review url: %s\n", $review->getUrl());
printf("Review verified: %s\n", $review->isVerified() ? 'yes' : 'no');
printf("Review Trust Score (between 0 and 100): %u\n", $review->getTrustScore()->getScore());
printf("Review Trust Score in stars (between 1 and 5): %u\n", $review->getTrustScore()->getStars());
printf("Review Trust Score: %s\n", $review->getTrustScore()->getReadableScore());
printf("Review Trust Score image url: %s\n", $review->getTrustScore()->getImageUrl('medium'));
printf("Review user name: %s\n", $review->getUser()->getName());
printf("Review user city: %s\n", $review->getUser()->getCity());
printf("Review user locale: %s\n", $review->getUser()->getLocale());
printf("Review user total reviews: %u\n", $review->getUser()->getTotalReviews());
printf("Review user verified: %s\n", $review->getUser()->isVerified() ? 'yes' : 'no');
printf("Review user profile image: %s\n", $review->getUser()->hasImage() ? 'yes' : 'no');
printf("Review user profile image url: %s\n", $review->getUser()->getImageUrl('i35'));
}
foreach ($trustpilot->getCategories() as $category) {
printf("Category name: %s\n", $category->getName());
printf("Category position: %u\n", $category->getPosition());
printf("Category total domains: %u\n", $category->getTotalDomain());
printf("Category position image url: %s\n", $category->getImageUrl('i280'));
}
} catch (Exception $e) {
die($e->getMessage());
}
bash
$ php composer.phar install --dev
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.