fix json to xml response api

This commit is contained in:
Marion Muszynski 2017-02-17 12:58:11 +01:00
parent ad26bde331
commit efed3b611e
2 changed files with 13 additions and 8 deletions

View File

@ -15,12 +15,16 @@ class ReviewIndicatorCollector
$returnedArray = array();
$tsId = Configuration::get('TRUSTED_SHOP_' . strtoupper(Language::getIsoById((int)$this->id_lang)) . '_ID');
try{
$jsonResult = $this->getApiResult($tsId);
$jsonObject = json_decode($jsonResult,true);
TrustedShopsCache::setReviewIndicatorCache($tsId, $jsonResult);
$returnedArray['result'] = $jsonObject['response']['data']['shop']['qualityIndicators']['reviewIndicator']['overallMark'];
$returnedArray['count'] = $jsonObject['response']['data']['shop']['qualityIndicators']['reviewIndicator']['activeReviewCount'];
$returnedArray['shop_name'] = $jsonObject['response']['data']['shop']['name'];
// $jsonResult = $this->getApiResult($tsId);
// $jsonObject = json_decode($jsonResult,true);
// $returnedArray['result'] = $jsonObject['response']['data']['shop']['qualityIndicators']['reviewIndicator']['overallMark'];
// $returnedArray['count'] = $jsonObject['response']['data']['shop']['qualityIndicators']['reviewIndicator']['activeReviewCount'];
// $returnedArray['shop_name'] = $jsonObject['response']['data']['shop']['name'];
$xmlResult = $this->getApiResult($tsId);
$xml = new SimpleXMLElement($xmlResult);
$returnedArray['result'] = $xml->data->shop->qualityIndicators->reviewIndicator->{'overallMark'};
$returnedArray['count'] = $xml->data->shop->qualityIndicators->reviewIndicator->activeReviewCount;
$returnedArray['shop_name'] = $xml->data->shop->name;
}catch(Exception $ex){
Logger::AddLog("file ReviewIndicatorCollector.php - " .$ex->getMessage(), 4, '0000001', 'User', '0');
}
@ -30,7 +34,7 @@ class ReviewIndicatorCollector
private function getApiResult($ts_id)
{
$apiUrl = 'http://api.trustedshops.com/rest/public/v2/shops/' . $ts_id . '/quality/reviews.json';
$apiUrl = 'http://api.trustedshops.com/rest/public/v2/shops/' . $ts_id . '/quality/reviews';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

View File

@ -168,6 +168,7 @@ class TrustedShopsBbb extends Module
'result' => $resultArray['result'],
'max' => self::TS_BEST_RATING,
'count' => $resultArray['count'],
'resultArray' => $resultArray
));
return $this->display(__FILE__, 'views/rich_snippets.tpl');
} else {
@ -193,7 +194,7 @@ class TrustedShopsBbb extends Module
global $smarty;
Tools::enableCache();
$smarty->cache_lifetime = 84000;
$smarty->cache_lifetime = 0;
return $this->isCached('rich_snippets.tpl', $cache_id);
}