PHP code example of jason6688 / walmart-api-client

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

    

jason6688 / walmart-api-client example snippets


use Walmart\Configuration;

$clientId = '<YOUR CLIENT ID>';
$clientSecret = '<YOUR CLIENT SECRET>';
$config = new Configuration([
    'clientId' => $clientId,
    'clientSecret' => $clientSecret,
]);

use Walmart\Configuration;
use Walmart\Walmart;

$config = new Configuration([
    'clientId' => $clientId,
    'clientSecret' => $clientSecret,
]);
$authApi = Walmart::marketplace($config)->auth();

// $authApi is an instance of Walmart\Apis\MP\US\AuthenticationApi
$tokenDetail = $authApi->getTokenDetail();
$tokenStatus = $tokenDetail->isValid;
var_dump($tokenStatus);

use Walmart\Configuration;
use Walmart\Walmart;

$config = new Configuration([
    'clientId' => $clientId,
    'clientSecret' => $clientSecret,
]);
$itemsApi = Walmart::marketplace($config)->items();

$response = $itemsApi->getAllItems(
    sku: '1234567890',
    lifecycleStatus: 'PUBLISHED',
    variantGroupId: '9876543210'
);

use Walmart\Configuration;
use Walmart\Walmart;

$config = new Configuration([
    'clientId' => $clientId,
    'clientSecret' => $clientSecret,
]);
$itemsApi = Walmart::marketplace($config)->items();

$response = $itemsApi->getAllItems(
    null,  // $nextCursor
    '1234567890',  // $sku,
    null,  // $offset
    null,  // $limit
    'PUBLISHED',  // $lifecycleStatus
    null,  // $publishedStatus
    '9876543210'  // $variantGroupId
);



use Walmart\Configuration;

$config = new Configuration([
    'clientId' => $clientId,
    'clientSecret' => $clientSecret,
]);
$config->setDebug(true);
// To redirect debug info to a file:
$config->setDebugFile('debug.log');