Download the PHP package retrowaver/allegro-rest-api-v2 without Composer

On this page you can find all versions of the php package retrowaver/allegro-rest-api-v2. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package allegro-rest-api-v2

php-allegro-rest-api-v2

Second version of a simple interface for Allegro REST API resources. Built on top of https://github.com/Wiatrogon/php-allegro-rest-api, which was rewritten for the most part.

Main differences are:

0. Installation

PHP Allegro REST API uses HTTPlug, and...

If a library depends on HTTPlug, it requires the virtual package php-http/client-implementation. A virtual package is used to declare that the library needs an implementation of the HTTPlug interfaces, but does not care which implementation specifically.

I recommend guzzle6 adapter, so run the following command before installing the PHP Allegro REST API library itself:

Now you're ready to run:

Note that you don't need to inject HTTP client and message factory into API client - HTTPlug uses discovery to find implementations automatically.

If you want to pass client / message factory explicitly to the API client, you can still do that (see Api.php constructor method).

1. Registering your app

In order to use Allegro REST API, you have to register your application (if you haven't done that already - see https://developer.allegro.pl/auth/#app).

2. Authorization

First, you need to get an authorization token. There are two different token managers provided for different types of authorization flows. Use one of them to get a token.

2.1. Authorization code flow

Learn how it works here: https://developer.allegro.pl/auth/#user

To use it with PHP Allegro REST API, do the following:

2.2. Client credentials flow

Client credentials flow doesn't require a user's permission. It's mostly used for accessing public data (searching offers, getting categories tree). Read more here: https://developer.allegro.pl/auth/#clientCredentialsFlow

2.3. Device flow

Device flow isn't supported right now. But you could always write your token manager and use the received token with API as usual. Read more here: https://developer.allegro.pl/auth/#DeviceFlow

3. Refreshing tokens

Authorization code tokens can be refreshed (see https://developer.allegro.pl/auth/#refresh-token).

4. Basic usage

4.1. Initializing

4.2. GET method

4.3. POST method

4.4. PUT method

4.5. DELETE method

4.6. Command

Some resources in API are only accesible using command pattern (read more here https://developer.allegro.pl/command/).

In the example above, UUID is generated automatically. If you want, you can generate it yourself, and pass it as an argument:

5. Headers

You can alter headers being sent with your requests. You can do it on request basis, or once for all subsequent requests.

5.1. Why alter headers?

You may want to alter headers for several different reasons, mainly:

5.2. Send a single request with custom headers

5.3. Set custom headers for subsequent requests

5.3.1. Replacing headers

Note that there are some custom headers set by default (Content-Type: application/vnd.allegro.public.v1+json and Accept: application/vnd.allegro.public.v1+json). If you want to replace them, use setCustomHeaders():

5.3.2. Adding headers

If you want to add one or more custom headers, use addCustomHeaders():

Note that existing custom headers won't be replaced when using this method.

6. Middleware

PHP Allegro REST API has a middleware feature, that allows you to alter requests and responses any way you like.

At this point, there's only one 'real' built-in middleware - ImageUploadMiddleware that alters request's URI in case of image upload request (from standard api.allegro.pl to image upload-specific upload.allegro.pl).

6.1. Create your own middleware

You can create your own middleware by creating a class implementing Retrowaver\Allegro\REST\Middleware\MiddlewareInterface and passing it into API constructor:

7. Other stuff

7.1. Sandbox

If you want to use API with sandbox environment, use Sandbox instead of Api, SandboxAuthorizationCodeTokenManager instead of AuthorizationCodeTokenManager and SandboxClientCredentialsTokenManager instead of ClientCredentialsTokenManager.

7.2. Tests

7.2.1. Unit tests

Run unit tests with vendor/bin/phpunit tests --color.

7.2.2. Sandbox tests

tests-sandbox contains tests sending real HTTP requests to sandbox environment. If you want to run those, rename tests-sandbox/config.php.dist to tests-sandbox/config.php, insert your sandbox credentials, and then run vendor/bin/phpunit tests-sandbox --color.


All versions of allegro-rest-api-v2 with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
psr/http-message Version ^1.0
php-http/client-implementation Version ^1.0
php-http/httplug Version ^2.0
php-http/message-factory Version ^1.0
php-http/discovery Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package retrowaver/allegro-rest-api-v2 contains the following files

Loading the files please wait ....