mikemiles86 / bazaarvoice-request
PHP library for making requests to Bazaarvoice API.
Installs: 52 672
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 2
Open Issues: 3
Requires
- php: >=5.5
- guzzlehttp/guzzle: ~6.0 || ~7.0
Requires (Dev)
- ext-curl: *
- phpunit/phpunit: ^4.0 || ^5.0
This package is auto-updated.
Last update: 2024-10-24 22:17:11 UTC
README
PHP library for making requests to Bazaarvoice APIs
Bazaarvoice Request Library
PHP library for making requests to Bazaarvoice APIs and handling responses.
Install
Via Composer
$ composer require mikemiles86/bazaarvoice-request
Usage
Creating a Request
$client = new \GuzzleHttp\Client(); $api_key = '12345abcd'; $bazaarvoice_request = new \BazaarvoiceRequest\BazaarvoiceRequest($client, $api_key);
Making a request
$client = new \GuzzleHttp\Client(); $api_key = '12345abcd'; $bazaarvoice_request = new \BazaarvoiceRequest\BazaarvoiceRequest($client, $api_key); $reviews = $bazaarvoice_request->apiRequest('data/reviews');
Making a staging request
$client = new \GuzzleHttp\Client(); $api_key = '12345abcd'; $bazaarvoice_request = new \BazaarvoiceRequest\BazaarvoiceRequest($client, $api_key); $reviews = $bazaarvoice_request->useStage()->apiRequest('data/reviews');
Making a request with additional configurations
$client = new \GuzzleHttp\Client(); $api_key = '12345abcd'; $bazaarvoice_request = new \BazaarvoiceRequest\BazaarvoiceRequest($client, $api_key); $configuration = [ 'method' => 'POST', 'options' => [ 'headers' => [ 'X-Forwarded-For' => '127.0.0.1', ], ], ]; $reviews = $bazaarvoice_request->apiRequest('data/reviews', $configuration);
$client = new \GuzzleHttp\Client(); $api_key = '12345abcd'; $bazaarvoice_request = new \BazaarvoiceRequest\BazaarvoiceRequest($client, $api_key); $configuration = [ 'arguments' => [ 'ProductId' => 'my_product_123', ], ]; $product_reviews = $bazaarvoice_request->->apiRequest('data/reviews', $configuration);
Get values from a response
$client = new \GuzzleHttp\Client(); $api_key = '12345abcd'; $bazaarvoice_request = new \BazaarvoiceRequest\BazaarvoiceRequest($client, $api_key); $response = $bazaarvoice_request->useStage()->apiRequest('data/reviews'); $reviews = $response->getResponse('Results');
Get errors from a response
$client = new \GuzzleHttp\Client(); $api_key = '12345abcd'; $bazaarvoice_request = new \BazaarvoiceRequest\BazaarvoiceRequest($client, $api_key); $response = $bazaarvoice_request->useStage()->apiRequest('data/reviews'); if ($response->getStatusCode() != '200' || $response->hasErrors()) { $errors = $response->getErrors(); }
Testing
$ composer test
Credits
License
The MIT License (MIT). Please see License File for more information.