1. Go to this page and download the library: Download highsidelabs/laravel-spapi 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/ */
highsidelabs / laravel-spapi example snippets
use Illuminate\Http\JsonResponse;
use Saloon\Exceptions\Request\RequestException;
use SellingPartnerApi\Seller\SellerConnector;
class SpApiController extends Controller
{
public function index(SellerConnector $connector): JsonResponse
{
try {
$api = $connector->sellersV1();
$result = $api->getMarketplaceParticipations();
return response()->json($result->json());
} catch (RequestException $e) {
$response = $e->getResponse();
return response()->json($response->json(), $e->getStatus());
}
}
}
use HighsideLabs\LaravelSpApi\Models\Credentials;
use HighsideLabs\LaravelSpApi\Models\Seller;
$seller = Seller::create(['name' => 'My Seller']);
$credentials = Credentials::create([
'seller_id' => $seller->id,
// You can find your selling partner ID/merchant ID by going to
// https://<regional-seller-central-domain>/sw/AccountInfo/MerchantToken/step/MerchantToken
'selling_partner_id' => '<AMAZON SELLER ID>',
// Can be NA, EU, or FE
'region' => 'NA',
// The LWA client ID and client secret for the SP API application these credentials were created with
'client_id' => 'amzn....',
'client_secret' => 'fec9/aw....',
// The LWA refresh token for this seller
'refresh_token' => 'IWeB|....',
]);