Bazaarvoice Request Library
, (*1)
PHP Wrapper for the Bazaarvoice Conversations API, (*2)
Install
Via Composer, (*3)
``` bash
$ composer require mikemiles86/bazaarvoice-conversations-api, (*4)
## Usage
### Creating a Conversations Object
``` php
$client = new \GuzzleHttp\Client();
$api_key = '12345abcd';
$bazaarvoice_request = new \BazaarvoiceRequest\BazaarvoiceRequest($client, $api_key);
$conversations_wrapper = new \BazaarvoiceConversations\BazaarvoiceConversations($bazaarvoice_request);
Content Types
All conversation API content types are supported., (*5)
Depending on the specific content type, data can be retrieved and sent to Bazaarvoice., (*6)
Get wrapper for Reviews content type.
``` php
$client = new \GuzzleHttp\Client();
$api_key = '12345abcd';
$bazaarvoice_request = new \BazaarvoiceRequest\BazaarvoiceRequest($client, $api_key);, (*7)
$conversations_wrapper = new \BazaarvoiceConversations\BazaarvoiceConversations($bazaarvoice_request);, (*8)
$reviews_wrapper = $conversations_wrapper->getContentType('Reviews');, (*9)
#### Make a raw request
``` php
$client = new \GuzzleHttp\Client();
$api_key = '12345abcd';
$bazaarvoice_request = new \BazaarvoiceRequest\BazaarvoiceRequest($client, $api_key);
$conversations_wrapper = new \BazaarvoiceConversations\BazaarvoiceConversations($bazaarvoice_request);
$response = $conversations_wrapper->apiRequest('data/reviews');
Retrieve Content
Retrieve content for Content Type by Id.
``` php
$client = new \GuzzleHttp\Client();
$api_key = '12345abcd';
$bazaarvoice_request = new \BazaarvoiceRequest\BazaarvoiceRequest($client, $api_key);, (*10)
$conversations_wrapper = new \BazaarvoiceConversations\BazaarvoiceConversations($bazaarvoice_request);, (*11)
$reviews_wrapper = $conversations_wrapper->getContentType('Reviews');, (*12)
$review = $reviews_wrapper->getResultById('review_1234');, (*13)
#### Retrieve content for Content Type by other parameters
``` php
$client = new \GuzzleHttp\Client();
$api_key = '12345abcd';
$bazaarvoice_request = new \BazaarvoiceRequest\BazaarvoiceRequest($client, $api_key);
$conversations_wrapper = new \BazaarvoiceConversations\BazaarvoiceConversations($bazaarvoice_request);
$reviews_wrapper = $conversations_wrapper->getContentType('Reviews');
$configuration = [
'arguments' => [
'ProductId' => 'my_product',
],
];
$response = $reviews_wrapper->retrieveRequest($configuration);
$product_reviews = $response->getResponse('Results');
Submit Content
``` php
$client = new \GuzzleHttp\Client();
$api_key = '12345abcd';
$bazaarvoice_request = new \BazaarvoiceRequest\BazaarvoiceRequest($client, $api_key);, (*14)
$conversations_wrapper = new \BazaarvoiceConversations\BazaarvoiceConversations($bazaarvoice_request);, (*15)
$reviews_wrapper = $conversations_wrapper->getContentType('Reviews');, (*16)
$reviews_submit_form = $reviews_wrapper->getSubmissionForm();, (*17)
#### Preview Submission
``` php
$client = new \GuzzleHttp\Client();
$api_key = '12345abcd';
$bazaarvoice_request = new \BazaarvoiceRequest\BazaarvoiceRequest($client, $api_key);
$conversations_wrapper = new \BazaarvoiceConversations\BazaarvoiceConversations($bazaarvoice_request);
$reviews_wrapper = $conversations_wrapper->getContentType('Reviews');
$submission_data = [
'Rating' => 5,
'ReviewText' => 'This is my Review',
];
$reviews_wrapper->previewSubmission($submission_data);
Submit Submission
``` php
$client = new \GuzzleHttp\Client();
$api_key = '12345abcd';
$bazaarvoice_request = new \BazaarvoiceRequest\BazaarvoiceRequest($client, $api_key);, (*18)
$conversations_wrapper = new \BazaarvoiceConversations\BazaarvoiceConversations($bazaarvoice_request);, (*19)
$reviews_wrapper = $conversations_wrapper->getContentType('Reviews');, (*20)
$submission_data = [
'Rating' => 5,
'ReviewText' => 'This is my Review',
];, (*21)
$reviews_wrapper->submitSubmission($submission_data);, (*22)
## Testing
``` bash
$ composer test
Credits
License
The MIT License (MIT). Please see License File for more information., (*23)