1. Go to this page and download the library: Download pdeans/miva-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$api->func('OrderList_Load_Query')
->count(10) // Limit number of records to return
->offset(5) // Set offset of first record to return
->sort('id') // Column sorting value
// ->sort('-id') // Column sorting value -descending
// ->sortDesc('id') // Column sorting value with explicit descending
->filter('Customer_ID', 1850) // Add a filter
->add();
// Add single header at a time
$api->addHeader('Custom-Header-Name', 'custom-header-value');
$api->addHeader('Cache-Control', 'no-cache');
// Add multiple headers in one swoop
$api->addHeaders([
'Custom-Header-Name'=> 'custom-header-value',
'Cache-Control'=> 'no-cache',
]);
// First add functions to request function list
$api->func('ProductList_Load_Query')
->search('code', 'prod1')
->add();
$api->func('CategoryList_Load_Query')
->sortDesc('id')
->count(5)
->filter('Category_Show', 'Active')
->add();
// Issue Api request - returns \pdeans\Miva\Api\Response object
$response = $api->send();
// Alternatively - returns raw JSON response
$response = $api->send(true);
// Print raw JSON Api response
$response = $api->func('ProductList_Load_Query')->add()->send();
echo '<pre>', $response->getBody(), '</pre>';
// Add functions to request function list
$api->func('ProductList_Load_Query')->add();
$api->func('OrderCustomFieldList_Load')->add();
$response = $api->send();
// Full response array
$results = $response->getResponse();
var_dump($results);
// Access function key on response array
var_dump($results['OrderCustomFieldList_Load']);
// Results are also iterable (same for result items)
foreach ($results as $result) {
var_dump($result);
}
// Return list of available functions in the response
var_dump($response->getFunctions());
// Isolate and return responses for specific function
var_dump($response->getFunction('ProductList_Load_Query'));
var_dump($response->getResponse('OrderCustomFieldList_Load'));
// Add functions to request function list
$api->func('ProductList_Load_Query')->add();
$api->func('ProductList_Load_Query')->count(5)->add();
$api->func('ProductList_Load_Query')->count(10)->add();
$response = $api->send();
/**
* Get the response "data" property for specific function.
* Defaults to the first iteration index result for the given function.
*/
var_dump($response->getData('ProductList_Load_Query'));
/**
* Use the optional second parameter to return the "data" property for
* a specific iteration index. The example below will return the "data"
* property for the 3rd iteration result on the given function.
*/
var_dump($response->getData('ProductList_Load_Query', 2));
// Add functions to request function list
$api->func('ProductList_Load_Query')->add();
$api->func('OrderCustomFieldList_Load')->add();
$response = $api->send();
// Output Api request authentication header value
echo $api->getPreviousRequest()->getHeader('X-Miva-API-Authorization')[0];
// Output the response HTTP status line
$prevResponse = $api->getPreviousResponse();
echo $prevResponse->getStatusCode(), ' ', $prevResponse->getReasonPhrase();
// Output Api endpoint url
echo $api->getUrl();
// Output request header list
$api->addHeader('Custom-Header-Name', 'custom-header-value');
var_dump($api->getHeaders());
// Output request function list
$api->func('ProductList_Load_Query')->add();
$api->func('OrderCustomFieldList_Load')->add();
var_dump($api->getFunctionList());
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.