The bridge between your app and Allegro Group servers
- full IDE autocompletion thanks to wsdl2phpgenerator
- simple, fluent, robust yet flexible, OOP interface
- support for custom logger
- library then writes some info to it to ease debugging
- support for custom cache
- caching is then enabled on a per call bases like this
$client->call()->cacheFor(10 * 60)->doSomeMethod()
- caching is then enabled on a per call bases like this
- support for parameter injection
- eg. session ID, country code, user ID, ...
- such info will be prepended to all requests that support it, so that you don't have to write them by hand all the time
- support for custom SOAP client
- this feature requires some tiny hacks (rerunning wsdl2phpgenerator with your custom config)
This project is currently in beta and is looking for testers who would provide feedback on its design and functionality, so that this library could reach a stable version. If you have any sugestions or complaints please fill an issue.
Add as a dependency to your composer.json
"require": {
"rindeal/allegro-php-client": "*"
}
or run composer require rindeal/allegro-php-client
to do everything automagically
require_once PATH_TO_AUTOLOADER;
// import appropriate tools
...
// Ok, first you need to provide your credentials which are required to use WebAPI.
// This library doesn't support logins with plain text passwords so in case you have one,
// use `hash_password.php` utility found in the `bin` directory
$credentials = new ApiCredentials(WEBAPI_KEY, USER_LOGIN, HASHED_PASSWORD);
// then you need to keep them in a session which is also bound to a specific region
$session = new Session($credentials, new Country('cz'));
// and as soon as you have provided us this info, you may set up the final client object
$client = new Client($session);
// you can call methods even when not authenticated yet
$res = $client->call()->doGetCountries(new DoGetCountriesRequest());
// but to do some real work you need to authenticate
$client->authenticate();
$res = $client->call()->doGetMyData(new DoGetMyDataRequest());
$userData = $res->getUserData();
printf("Hello %s %s!\n", $userData->getUserFirstName(), $userData->getUserLastName());
Another version of the authentication worklfow:
...
$credentials = new ApiCredentials(WEBAPI_KEY);
...
$client = new Client($session);
...
$client->authenticate(USER_LOGIN, HASHED_PASSWORD);
or
...
$credentials = new ApiCredentials(WEBAPI_KEY);
...
$credentials->userLogin = USER_LOGIN;
...
$client = new Client($session);
...
$credentials->hashedPassword = HASHED_PASSWORD;
...
$client->authenticate();
Primary targets of this client are Allegro.pl and Aukro.cz, but feel free to adopt it for your region.
- Licensed under LGPL-3.0 (human readable form, full license)
- generally put, the license should allow anyone to use this library (even in commercial projects) as long as its source code stays untouched and its usage disclosed
This project is not affiliated with nor supported by Allegro Group in any way.