This package implements PHP client for OLX Partner API.
To install the package to your project via Composer simply run:
composer require matasarei/olx-api-client-v2Official OLX API documentation and developers portal:
Check the troubleshooting section if you have any issues.
use Gentor\Olx\Api\Client;
use Gentor\Olx\Api\Credentials;
$credentials = new Credentials('your_client_id', 'your_client_secret');
$client = new Client($credentials, Client::OLX_UA);
// Create an advert
$response = $client->adverts()->create([
'title' => 'My Product',
'description' => 'Product description...',
'category_id' => 123,
// ... other required fields
]);
// Access the created advert data
$advertData = $response['data'];
echo "Created advert ID: " . $advertData['id'];
echo "Status: " . $advertData['status'];All OLX API responses wrap the actual data in a data key according to the official API specification:
// What you get from the API:
[
'data' => [
'id' => 905890605,
'status' => 'active',
// ... other advert fields
]
]
// Access the actual data:
$response = $client->adverts()->create($request);
$advertData = $response['data'];This response format applies to advert-related endpoints, for example:
GET /advertsreturns['data' => [array of adverts]]POST /advertsreturns['data' => {advert object}]GET /adverts/{id}returns['data' => {advert object}]PUT /adverts/{id}returns['data' => {advert object}]
Other endpoints may have different response structures. Please refer to the official OLX API documentation for details on the response format of each endpoint.
- Install vendors
docker run --rm -v $(pwd):/app -w /app composer:lts composer install- Run tests
docker run --rm -v $(pwd):/app -w /app composer:lts vendor/bin/phpunit