Get Reviews from ResellerRatings.com via JSON with OAuth in PHP
This will work only if you have a seller account with ResellerRatings.com.
Store this command in a file named token.sh (Replace CLIENT_ID and CLIENT_SECRET with your values available in your ResellerRatings dashboard)
curl --data "grant_type=client_credentials&client_id=<CLIENT_ID>&client_secret=<CLIENT_SECRET>" https://api.resellerratings.com/oauth/access_token > token.json
CLIENT_ID: Your Client ID as assigned in the Portal
CLIENT_SECRET: Your Client Secret as assigned in the Portal
Now run this reviews.php file in your browser :
<?php
$json = getJSONData(<SELLER_ID>); # Replace <SELLER_ID> with your seller ID
if (isset($json->status_code))
{
if ($json->status_code == 401)
{
shell_exec("bash token.sh");
$json = getJSONData();
}
else
{
print_r($json);
exit;
}
}
$count = 0;
for ($i = 0; $i < count($json->data); $i++)
{
if (!($json->data[$i]->rating == 4 || $json->data[$i]->rating == 5)) continue;
$count++;
echo "<b>User</b> : ".$json->data[$i]->username; echo "<br/>";
echo "<b>Title</b> : ".$json->data[$i]->title; echo "<br/>";
echo "<b>Review</b> : ".$json->data[$i]->review; echo "<br/>";
echo "<b>Rating</b> : ".$json->data[$i]->rating; echo "<br/>";
echo "<hr/>";
if ($count == 10) break;
}
exit;
function getJSONData($seller)
{
$content = file_get_contents('token.json');
$json_content = json_decode($content);
$access_token = $json_content->access_token;
$ch = curl_init("https://api.resellerratings.com/v1/seller/$seller/reviews?perPage=30");
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Authorization: Bearer $access_token"]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);
return json_decode($output);
}
?>
There's a list of operations you can do with ResellerRatings API - here's the doc of all operations : api.resellerratings.com/api/documentation