PHP code example of ircykk / allegro-api

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

    

ircykk / allegro-api example snippets




// Composer autoload
t = new \Ircykk\AllegroApi\Client($credentials);

// Redirect to allegro for authenticate and get back with code
if (!isset($_GET['code'])) {
    header('Location: '.$client->getAuthUrl());
} else {
    $token = $client->fetchAccessTokenWithAuthCode($_GET['code']);

    // Store access token...
}

$token = $client->fetchAccessTokenWithClientCredentials();

$code = $client->getAuthUserCode();

$code = ...

$token = $client->fetchAccessTokenWithDeviceCode($code->device_code);



// Composer autoload
= ...

$client = new \Ircykk\AllegroApi\Client($credentials);
$client->authenticate($token);

$categories = $client->sale()->categories()->all();

$credentials = ...

// WebApi SOAP client
$soapClient = new \Ircykk\AllegroApi\WebapiClient($credentials);

$categories = $soapClient->webApi()->getCatsDataLimit(0, 10);

$credentials = new \Ircykk\AllegroApi\Credentials(
    ...
    true // Sandbox
);

$credentials = ...
$client = new Client($credentials);

$cache = new FilesystemAdapter();
$client->addCache($cache, ['default_ttl' => 3600]);

$credentials = ...
$client = new Client($credentials);

$logger = new Logger('api');
$logger->pushHandler(
    new StreamHandler(__DIR__.'/api.log', Logger::DEBUG)
);
$loggerPlugin = new LoggerPlugin($logger);
$client->addPlugin($loggerPlugin);

...
$headerDefaultsPlugin = new HeaderDefaultsPlugin([
    'Accept-Language' => 'en-US'
]);
$client->addPlugin($headerDefaultsPlugin);
bash
composer