PHP code example of mallgroup / mpapi-client

1. Go to this page and download the library: Download mallgroup/mpapi-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/ */

    

mallgroup / mpapi-client example snippets


 declare(strict_types=1);

use MpApiClient\Common\Authenticators\ClientIdAuthenticator;
use MpApiClient\MpApiClient;
use MpApiClient\MpApiClientOptions;

ize MP API Client
$client = MpApiClient::createFromOptions('my-app-name', $options);

// 3. Get brand client
$brandClient = $client->brand();

 declare(strict_types=1);

use GuzzleHttp\Client;
use GuzzleHttp\Handler\CurlHandler;
use GuzzleHttp\HandlerStack;
use MpApiClient\Brand\BrandClient;
use MpApiClient\Common\Authenticators\ClientIdAuthenticator;
use MpApiClient\MpApiClient;
use MpApiClient\MpApiClientOptions;

ck = HandlerStack::create($handler);
$handlerStack->push($authenticator->getHandler());

$httpClient = new Client(
    [
        'base_uri'        => 'https://mpapi.mallgroup.com/v1/',
        'timeout'         => 10,
        'allow_redirects' => true,
        'handler'         => $handlerStack,
    ]
);

// 2.2. Create Guzzle client using MpApiClientOptions object
$options = new MpApiClientOptions($authenticator);
$options->setTimeout(30);

$httpClient = new Client($options->getGuzzleOptionsArray());

// 3. Create MpApiClient and BrandClient using custom Guzzle client
$client      = new MpApiClient($httpClient, 'my-app-name')
$brandClient = new BrandClient($httpClient, 'my-app-name')