1. Go to this page and download the library: Download eoko/magento2-client 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/ */
eoko / magento2-client example snippets
oko\Magento2\Client\MagentoClientBuilder;
use Eoko\Magento2\Client\Security\AdminAuthentication;
// We initiate the client builder
$clientBuilder = new MagentoClientBuilder('http://m2.localhost:8000/rest/default');
// Create an unauthenticated client
$unAuthenticatedClient = $clientBuilder->buildAuthenticatedClient();
// Get an admin token
echo $unAuthenticatedClient->getAdminTokenApi()->getAdminToken('magento2', 'magento2');
Eoko\Magento2\Client\MagentoClientBuilder;
use Eoko\Magento2\Client\Security\AdminAuthentication;
$token = 'youtoken...';
// Authentication from admin token
$authentication = AdminAuthentication::fromAdminToken($token);
// Create an authenticated client
$authenticatedClient = $clientBuilder->buildAuthenticatedClient($authentication);