PHP code example of amorvan / ebay-inventory-sdk-php

1. Go to this page and download the library: Download amorvan/ebay-inventory-sdk-php 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/ */

    

amorvan / ebay-inventory-sdk-php example snippets



use SapientPro\EbayInventorySDK\Configuration;
use SapientPro\EbayInventorySDK\Api\InventoryItemApi;
use SapientPro\EbayInventorySDK\Models\BulkInventoryItem;

// Configure OAuth2 access token for authorization: api_auth
$config = Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');

$apiInstance = new InventoryItemApi(
    config: $config
);
// you can create and fill a Model class that implements EbayModelInterface using fromArray() method
// exception will be thrown if a property does not exist in the model class
$body = BulkInventoryItem::fromArray([]);

try {
    $result = $apiInstance->bulkCreateOrReplaceInventoryItem($body);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling InventoryItemApi->bulkCreateOrReplaceInventoryItem: ', $e->getMessage(), PHP_EOL;
}

Item::fromArray([
    'price' => ConvertedAmount::fromArray([
        'value' => '6.90',
        'currency' => CurrencyCodeEnum::USD
    )]
])

Item::fromPlainArray([
    'price' => [
        'value' => '6.90',
        'currency' => CurrencyCodeEnum::USD
    ]
])

Item::fromJson('{"price": {"value": "6.90", "currency": "USD"}}')