Download the PHP package mcrock/allegroapi without Composer
On this page you can find all versions of the php package mcrock/allegroapi. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mcrock/allegroapi
More information about mcrock/allegroapi
Files in mcrock/allegroapi
Package allegroapi
Short Description library making allegro rest and soap api using easier
License MIT
Informations about the package allegroapi
allegroapi PHP SDK
Library that makes allegro rest and soap api using easier
Installation
This lib should be installed with composer
Requirements
- PHP >= 7.1 (please forgive me, i think it's time to say goodbye to PHP5)
REST Api usage
Usage of allegro rest api is very simple with this library.
Prepare credentials
First, you should create object Credentials, or implement CredentialsInterface in your own class.
Get your token
Every operation in REST Api needs OAuth token. You can easily get it with this library.
After logging in Allegro.pl you will be redirected to your RedirectUrl with auth code in query string. What next?
You can store Token serializing it, or storing it's values. You can also implement TokenInterface to create a solution that suits your needs.
If your token has expired, just generate new one with this method:
Usage of API methods
The best explanation how to use it will be some example, so here it is:
With that simple way you can use all api methods. Alternative method is use prepared request classes.
Ready-to-use request classes location: here I already covered almost all rest api methods. I'll try to create all to cover 100%.
Of course you can create your own, just implement RequestInterface. It's very simple.
Example:
Exceptions
I've created two Exception classes: InvalidRequestMethodException - just means that you used wrong HTTP method name in your request. UnauthorizedClientException - you should catch it just to know when refreshing token is necessary.
SOAP API
There is a class AllegroApiSoapClient inside this lib, and you can use it, by so far I got no time to finish it. It should work ok, but I need some time to document it.
Sandbox
Allegro Api Sandbox is problematic. It almost never works properly, so if you want to test your app, just use production API. Trust me, there is no good reason to implement Sandbox endpoints :)
Few ending words
If you have any suggestions, or noticed any issues, feel free to report it, or contact me.
All versions of allegroapi with dependencies
guzzlehttp/guzzle Version ^6.3
ramsey/uuid Version ^3.7
lcobucci/jwt Version ^3.2
wsdl2phpgenerator/wsdl2phpgenerator Version ^3.4