dev-master
9999999-devAn simple library for parsing and displaying Trustpilot reviews.
MIT
The Requires
- php >=5.4
trustpilot trustpilot api
Wallogit.com
2017 © Pedro Peláez
An simple library for parsing and displaying Trustpilot reviews.
This library is a simple class for displaying TrustPilot reviews., (*2)
Requires a minimum PHP version of 5.4., (*3)
Execute this command in your terminal:, (*4)
composer require edwinhoksberg/trustpilot-api:dev-master
Or add this line to your composer.json:, (*5)
"require": {
"edwinhoksberg/trustpilot-api": "dev-master"
}
and run:, (*6)
composer update
Add this line add the top of your php application:, (*7)
require 'src/TrustPilot.php';
// Initialize the API
$trustpilot = new \TrustPilot\Api('1234567');
// Show site total score $trustpilot->getRatingScore(); // Output: 88
// Show site stars $trustpilot->getRatingStars(); // Output: 4
// Show number of stars for a specific star $stars = $trustpilot->getReviewStarDistrubution(); echo 'This site has ' . $stars[5] . ' ratings of five stars.'; // Output: This site has 27 ratings of five stars.
// Dump the data from a random review
var_dump(
$trustpilot->getRandomReview()
);
// Output:
array(10) {
["title"]=>
string(22) "Very good and excellent prices"
["content"]=>
string(22) "Very good and excellent prices, etc..."
["name"]=>
string(21) "John Doe"
["url"]=>
string(58) "http://www.trustpilot.nl/review/www.mysite.nl#1234567"
["language"]=>
string(5) "en-US"
["score"]=>
int(100)
["stars"]=>
int(5)
["score_value"]=>
string(10) "Excellent"
["timestamp"]=>
int(1418866304)
["rating_images"]=>
array(3) {
["small"]=>
string(50) "//s.trustpilot.com/images/tpelements/stars/s/5.png"
["medium"]=>
string(50) "//s.trustpilot.com/images/tpelements/stars/m/5.png"
["large"]=>
string(50) "//s.trustpilot.com/images/tpelements/stars/l/5.png"
}
}
// Display all reviews
var_dump(
$trustpilot->getAllReviews()
);
// Output:
array(1) {
[0]=>
array(10) {
["title"]=>
string(22) "Very good and excellent prices"
["content"]=>
string(22) "Very good and excellent prices, etc..."
["name"]=>
string(21) "John Doe"
["url"]=>
string(58) "http://www.trustpilot.nl/review/www.mysite.nl#1234567"
["language"]=>
string(5) "en-US"
["score"]=>
int(100)
["stars"]=>
int(5)
["score_value"]=>
string(10) "Excellent"
["timestamp"]=>
int(1418866304)
["rating_images"]=>
array(3) {
["small"]=>
string(50) "//s.trustpilot.com/images/tpelements/stars/s/5.png"
["medium"]=>
string(50) "//s.trustpilot.com/images/tpelements/stars/m/5.png"
["large"]=>
string(50) "//s.trustpilot.com/images/tpelements/stars/l/5.png"
}
}
[1]=>
...
[2]=>
...
}
An simple library for parsing and displaying Trustpilot reviews.
MIT
trustpilot trustpilot api