Download the PHP package vt-parhomenko/olx-ua-api-sdk without Composer

On this page you can find all versions of the php package vt-parhomenko/olx-ua-api-sdk. 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 olx-ua-api-sdk

OLX Partner API — PHP SDK

A lightweight PHP client for the OLX Partner REST API. It wraps authentication (OAuth2), request signing, response parsing and error handling behind a small, fluent facade.

Supports OLX in Ukraine, Poland, Bulgaria, Romania, Kazakhstan and Portugal.

Requirements

Installation

Quick start

OlxFactory::get() accepts either a Country enum case (recommended) or a plain country code string ('ua', 'pl', 'bg', 'ro', 'kz', 'pt'). An unknown country throws Parhomenko\Olx\Exceptions\UnknownCountryException.

The third argument, $update_token, when true, checks the token on construction and transparently refreshes it via the refresh token if it is expired.

HTTP client options

The optional fourth argument, $httpOptions (since 3.1), is passed to the underlying Guzzle client and applies to every request — resource calls as well as the OAuth token requests. By default no options are set, and Guzzle then waits indefinitely for a response, so setting at least timeout and connect_timeout is strongly recommended for queue workers and other long-running processes.

The same array can be passed to new Api($baseUri, $credentials, $update_token, $httpOptions). A base_uri key in the options is ignored: the base URI of the selected country (or the $baseUri argument of Api) always wins. A timeout surfaces as GuzzleHttp\Exception\ConnectException (a GuzzleException), not as an OLX exception.

Authentication (OAuth2)

Only client_id and client_secret are strictly required. The full credential set is:

Key Required Description
client_id yes OAuth client id
client_secret yes OAuth client secret
access_token no Stored access token
refresh_token no Stored refresh token
token_type no Defaults to bearer
scope no Defaults to read write v2
grant_type no Defaults to authorization_code
expires_in no Token lifetime in seconds (used to detect expiry)
updated_at no ISO-8601, e.g. date('c'), when issued/stored

Note: store expires_in whenever you store an access_token. If you supply an access_token and updated_at but omit expires_in, the token is treated as already expired and refreshed on the first call (which needs a valid refresh_token). Prefer persisting the value returned by Authenticator::getTokenUpdatedAt() for updated_at — it is offset-aware, so expiry is evaluated correctly even when tokens are stored and read on hosts with different timezones.

Authorization code flow

Refreshing tokens

A failed refresh throws Parhomenko\Olx\Exceptions\RefreshTokenException (use getError() / getErrorDescription() for OLX error details).

Client credentials (no user context)

For read-only access to public catalog data (categories, cities, currencies, …) without a user, authenticate with the client_credentials grant:

Note: this grant cannot create or manage adverts — use the authorization code flow for user-scoped actions.

Resources

Every resource is reached through the facade, e.g. $olx->adverts(). List endpoints return the decoded data payload as an array; command endpoints return void and throw a Parhomenko\Olx\Exceptions\BaseOlxException on failure.

Adverts — $olx->adverts()

Categories — $olx->categories()

Locations

Reference data

Users — $olx->users()

Packets — $olx->packets()

Paid features — $olx->paidFeatures()

Business profile — $olx->usersBusiness()

Threads & messages

Payments & error handling

To avoid the payment errors described in the OLX docs (insufficient credits, invalid payment method, missing packet variant), check state before purchasing:

Error handling

Every HTTP error is mapped to a typed exception. All of them extend Parhomenko\Olx\Exceptions\BaseOlxException and expose getTitle() and getDetail().

Status Exception
400 BadRequestException
400 ValidationException (when the body contains validation errors; adds getValidation())
401 UnauthorizedException
403 ForbiddenException
404 NotFoundException
406 NotAcceptableException
415 UnsupportedMediaTypeException
429 CallLimitException
5xx ServerException
other BadRequestException

Supported countries

The Parhomenko\Olx\Country enum is the single source of truth:

Case Code Base URI
Country::UA ua https://www.olx.ua/
Country::PL pl https://www.olx.pl/
Country::BG bg https://www.olx.bg/
Country::RO ro https://www.olx.ro/
Country::KZ kz https://www.olx.kz/
Country::PT pt https://www.olx.pt/

Upgrading from 2.x to 3.0

3.0 is a breaking release. The most common migrations:

1. PHP 8.1+ is now required

The minimum supported version moved from PHP 7.0 to 8.1 (the Country enum relies on it).

2. OlxFactory::get() signature

The first parameter was renamed $country_code → $country and is now typed string|Country. Only named-argument calls (get(country_code: 'ua')) need updating to get(country: 'ua').

3. Typed exceptions everywhere

In 2.x several resources (categories, cities, regions, districts, currencies, languages, users, threads, messages) let raw GuzzleHttp\Exception\* propagate. In 3.0 all resources throw the typed Parhomenko\Olx\Exceptions\* hierarchy (see the table above). Replace any catch (GuzzleHttp\Exception\ClientException ...) around these calls with the relevant OLX exception (or the BaseOlxException base type).

4. Advert deletion changed

delete_notactive() was removed; delete() now performs a single DELETE request and no longer deactivates the advert first.

5. Thread methods renamed to camelCase

The snake_case thread methods mark_as_read(), set_favourite() and unset_favourite() were removed. Use the camelCase equivalents markAsRead(), setFavourite() and unsetFavourite().

6. Messages::get() now paginates

offset / limit arguments were previously ignored and are now sent to the API. If you relied on always receiving the first page, pass the arguments explicitly.

7. New facade accessors

$olx->threads() and $olx->messages() are now reachable from the facade (the classes existed in 2.x but could not be obtained through Api).

8. Authentication via authenticator()

The OAuth/token class is Parhomenko\Olx\Api\Authenticator (it handles authentication, not user data — that is the separate Users resource), reached through $olx->authenticator():

9. OlxApiInterface

The facade interface is OlxApiInterface (no Hungarian I prefix). Replace any IOlxApi type hints with OlxApiInterface.

10. Command methods return void

Methods that signal success/failure (and previously returned an always-true bool) now return void and throw a BaseOlxException on failure: Adverts::activate/deactivate/delete/deleteStatistic/deleteLogo, all Threads command methods, and UsersBusiness::deleteLogo/deleteBanner.

11. Credentials value object (optional)

Credentials may be passed as a typed Parhomenko\Olx\Credentials object; the associative-array form still works (normalised via Credentials::fromArray()):

Development

License

MIT


All versions of olx-ua-api-sdk with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1.0
guzzlehttp/guzzle Version ^7.5
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 vt-parhomenko/olx-ua-api-sdk contains the following files

Loading the files please wait ...