Skip to content

Instantly share code, notes, and snippets.

@charleshimmer
Last active December 12, 2015 02:08
Show Gist options
  • Save charleshimmer/4695898 to your computer and use it in GitHub Desktop.
Save charleshimmer/4695898 to your computer and use it in GitHub Desktop.
Possible PHP BV SDK
<?php
// include bv sdk
require('BVsdk.php');
// call constructor method passing client specific data
$bv = BV(array(
'productId' => 'test1',
'currentPageUrl' => 'http://www.client.com/productId/page.php',
'staging' => TRUE, // boolean,
'seoKey' => 'akd923jaddflkj20gjhasdf', // provided by BV
'deploymentZone' => 'Main Site', // optional will default to Main Site if ommited
'locale' => 'en_us' // optional, will default to en_us if ommitted
));
// $bv object will expose five public methods intended to be used by the client.
// These five methods should provide enough flexbility for the client to whatever
// they need to.
/**
* These methods will return the BV SEO payload only. This means the client will have
* to do the traditional client side integration like they do today in order to render
* the display. This is also what clients who need to customize the client side integration
* would use.
*
* $bv->reviews->renderSEO();
* $bv->questions->renderSEO();
* /
/**
* These three methods would power both display and SEO.
*
* $bv->reviews->renderSummary();
* $bv->reviews->renderContainer(); // does both display and SEO
* $bv->questions->renderContainer(); // does both display and SEO
* /
<html>
<body>
<h1>Hi, I am a test page</h1>
<!-- Review Summary Container -->".
<?php echo $bv->reviews->renderSummary();?>
<div>Main page content is here</div>
<!-- Review Container -->
<?php echo $bv->reviews->renderContainer();?>
<!-- Question & Answer Container -->
<?php echo $bv->questions->renderContainer();?>
</body>
</html>
<html>
<head>
<script src="//display.ugc.bazaarvoice.com/ClientName/DeploymentZone/Lang/Locale/bvapi.js"></script>
<script>
$BV.ui('rr','show_reviews',{
productId: 'test1'
});
$BV.ui('qa', 'show_questions', {
productId: 'test1'
});
</script>
</head>
<body>
<h1>Hi, I am a test page</h1>
<!-- Review Summary Container -->".
<div id="BVRRSummaryContainer"></div>
<div>Main page content is here</div>
<!-- Review Container -->
<div id="BVRRContainer">
<?php echo $bv->reviews->renderSEO();?>
</div>
<!-- Question & Answer Container -->
<div id="BVQAContainer">
<?php echo $bv->questions->renderSEO();?>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment