如何拨打 API 电话以获取 bazaarvoice 扩展中的评论?reviews.phtml 代码如下所述
How to make an API call to get the reviews in bazaarvoice extension?reviews.phtml code is mentioned below
<?php if ($this->getIsEnabled()):?>
<?php $doShowContentJs = Mage::getStoreConfig('bazaarvoice/rr/do_show_content_js');
$seoContent = $this->getSEOContent();
?>
<div id="BVRRContainer">
<?php echo $seoContent ?>
</div>
<script type="text/javascript">
$BV.ui( 'rr', 'show_reviews', {
doShowContent : function () {
<?php echo $doShowContentJs ?>
}
});
</script>
<?php endif; ?>
这里的回答提供了一个如何检索评论的示例,但我将提供一个片段:
$(document).ready(function(){
$.ajax({
url: "https://stg.api.bazaarvoice.com/data/reviews.json?apiversion=5.4&passkey=***ENTER PASSKEY HERE***&filter=productid:***PRODUCTID***",
data: "json",
success: function(data){
console.log(data);
for (i in data['Results']){
var info = data['Results'][i];
console.log(info.AuthorId + " || " + info.ReviewText);
}
}
})
});
<?php if ($this->getIsEnabled()):?>
<?php $doShowContentJs = Mage::getStoreConfig('bazaarvoice/rr/do_show_content_js');
$seoContent = $this->getSEOContent();
?>
<div id="BVRRContainer">
<?php echo $seoContent ?>
</div>
<script type="text/javascript">
$BV.ui( 'rr', 'show_reviews', {
doShowContent : function () {
<?php echo $doShowContentJs ?>
}
});
</script>
<?php endif; ?>
$(document).ready(function(){
$.ajax({
url: "https://stg.api.bazaarvoice.com/data/reviews.json?apiversion=5.4&passkey=***ENTER PASSKEY HERE***&filter=productid:***PRODUCTID***",
data: "json",
success: function(data){
console.log(data);
for (i in data['Results']){
var info = data['Results'][i];
console.log(info.AuthorId + " || " + info.ReviewText);
}
}
})
});